summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-09-27 12:06:35 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-09-27 12:06:35 -0700
commit5dedc4c400ec71e46a9ea641dd18c914b11c1096 (patch)
treeda71658e100676d8d144db9a2c1045c10e5ebe03
parent3eb1c0f675a8930678172fc867e94582189aad26 (diff)
downloadbrdo-5dedc4c400ec71e46a9ea641dd18c914b11c1096.tar.gz
brdo-5dedc4c400ec71e46a9ea641dd18c914b11c1096.tar.bz2
Issue #1226796 by sun, catch, Damien Tournoud: Fixed Not equal operator '!=' is not supported by all databases, must be '<>'.
-rw-r--r--includes/entity.inc21
-rw-r--r--includes/update.inc2
-rw-r--r--modules/field/tests/field_test.storage.inc2
-rw-r--r--modules/simpletest/tests/entity_query.test86
-rw-r--r--modules/system/system.admin.inc2
-rw-r--r--modules/system/system.api.php2
-rw-r--r--modules/system/system.module2
7 files changed, 109 insertions, 8 deletions
diff --git a/includes/entity.inc b/includes/entity.inc
index 8ea83a88e..45d697c80 100644
--- a/includes/entity.inc
+++ b/includes/entity.inc
@@ -606,7 +606,7 @@ class EntityFieldQuery {
* dependent on $operator.
* @param $operator
* Possible values:
- * - '=', '!=', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
+ * - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
* operators expect $value to be a literal of the same type as the
* column.
* - 'IN', 'NOT IN': These operators expect $value to be an array of
@@ -620,6 +620,11 @@ class EntityFieldQuery {
* The called object.
*/
public function entityCondition($name, $value, $operator = NULL) {
+ // The '!=' operator is deprecated in favour of the '<>' operator since the
+ // latter is ANSI SQL compatible.
+ if ($operator == '!=') {
+ $operator = '<>';
+ }
$this->entityConditions[$name] = array(
'value' => $value,
'operator' => $operator,
@@ -724,7 +729,7 @@ class EntityFieldQuery {
* element in the array is dependent on $operator.
* @param $operator
* Possible values:
- * - '=', '!=', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
+ * - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
* operators expect $value to be a literal of the same type as the
* column.
* - 'IN', 'NOT IN': These operators expect $value to be an array of
@@ -751,6 +756,11 @@ class EntityFieldQuery {
* The called object.
*/
protected function addFieldCondition(&$conditions, $field, $column = NULL, $value = NULL, $operator = NULL, $delta_group = NULL, $language_group = NULL) {
+ // The '!=' operator is deprecated in favour of the '<>' operator since the
+ // latter is ANSI SQL compatible.
+ if ($operator == '!=') {
+ $operator = '<>';
+ }
if (is_scalar($field)) {
$field_definition = field_info_field($field);
if (empty($field_definition)) {
@@ -791,7 +801,7 @@ class EntityFieldQuery {
* array is dependent on $operator.
* @param $operator
* Possible values:
- * - '=', '!=', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
+ * - '=', '<>', '>', '>=', '<', '<=', 'STARTS_WITH', 'CONTAINS': These
* operators expect $value to be a literal of the same type as the
* column.
* - 'IN', 'NOT IN': These operators expect $value to be an array of
@@ -805,6 +815,11 @@ class EntityFieldQuery {
* The called object.
*/
public function propertyCondition($column, $value, $operator = NULL) {
+ // The '!=' operator is deprecated in favour of the '<>' operator since the
+ // latter is ANSI SQL compatible.
+ if ($operator == '!=') {
+ $operator = '<>';
+ }
$this->propertyConditions[] = array(
'column' => $column,
'value' => $value,
diff --git a/includes/update.inc b/includes/update.inc
index 35be17ab2..3a131083d 100644
--- a/includes/update.inc
+++ b/includes/update.inc
@@ -1426,7 +1426,7 @@ function update_retrieve_dependencies() {
$return = array();
// Get a list of installed modules, arranged so that we invoke their hooks in
// the same order that module_invoke_all() does.
- $modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version != :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol();
+ $modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND schema_version <> :schema ORDER BY weight ASC, name ASC", array(':schema' => SCHEMA_UNINSTALLED))->fetchCol();
foreach ($modules as $module) {
$function = $module . '_update_dependencies';
if (function_exists($function)) {
diff --git a/modules/field/tests/field_test.storage.inc b/modules/field/tests/field_test.storage.inc
index 3ca322dd7..a26af1765 100644
--- a/modules/field/tests/field_test.storage.inc
+++ b/modules/field/tests/field_test.storage.inc
@@ -282,7 +282,7 @@ function field_test_field_storage_query($field_id, $conditions, $count, &$cursor
case '=':
$match = $match && $row->{$column} == $value;
break;
- case '!=':
+ case '<>':
case '<':
case '<=':
case '>':
diff --git a/modules/simpletest/tests/entity_query.test b/modules/simpletest/tests/entity_query.test
index 0fe8106ef..3c53eae47 100644
--- a/modules/simpletest/tests/entity_query.test
+++ b/modules/simpletest/tests/entity_query.test
@@ -722,6 +722,31 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'test_entity_bundle_key')
+ ->propertyCondition('ftid', 3, '<>');
+ $this->assertEntityFieldQuery($query, array(
+ array('test_entity_bundle_key', 1),
+ array('test_entity_bundle_key', 2),
+ array('test_entity_bundle_key', 4),
+ array('test_entity_bundle_key', 5),
+ array('test_entity_bundle_key', 6),
+ ), t('Test the "not equal to" operation on a property.'));
+
+ $query = new EntityFieldQuery();
+ $query->fieldCondition($this->fields[0], 'value', 3, '<>');
+ $this->assertEntityFieldQuery($query, array(
+ array('test_entity_bundle_key', 1),
+ array('test_entity_bundle_key', 2),
+ array('test_entity_bundle_key', 4),
+ array('test_entity_bundle_key', 5),
+ array('test_entity_bundle_key', 6),
+ array('test_entity', 1),
+ array('test_entity', 2),
+ array('test_entity', 4),
+ ), t('Test the "not equal to" operation on a field.'));
+
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity_bundle_key')
->propertyCondition('ftid', 3, '!=');
$this->assertEntityFieldQuery($query, array(
array('test_entity_bundle_key', 1),
@@ -1088,6 +1113,15 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'test_entity', '=')
+ ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>');
+ $this->assertEntityFieldQuery($query, array(
+ array('test_entity', 1),
+ ), t('Test with a language meta condition.'));
+
+ // Test language field meta condition.
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity', '=')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=');
$this->assertEntityFieldQuery($query, array(
array('test_entity', 1),
@@ -1115,6 +1149,16 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$query
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
+ ->fieldLanguageCondition($this->fields[0], 'en', '<>', NULL, 'group');
+ $this->assertEntityFieldQuery($query, array(
+ array('test_entity', 1),
+ ), t('Test with a grouped language meta condition.'));
+
+ // Test language grouping.
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity', '=')
+ ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
->fieldLanguageCondition($this->fields[0], 'en', '!=', NULL, 'group');
$this->assertEntityFieldQuery($query, array(
array('test_entity', 1),
@@ -1124,6 +1168,13 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$query
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
+ ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', NULL, 'group');
+ $this->assertEntityFieldQuery($query, array(), t('Test with a grouped language meta condition (empty result set).'));
+
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity', '=')
+ ->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=', NULL, 'group');
$this->assertEntityFieldQuery($query, array(), t('Test with a grouped language meta condition (empty result set).'));
@@ -1133,6 +1184,17 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
+ ->fieldLanguageCondition($this->fields[0], 'en', '<>', 'delta', 'language');
+ $this->assertEntityFieldQuery($query, array(
+ array('test_entity', 1),
+ ), t('Test with a grouped delta + language meta condition.'));
+
+ // Test delta and language grouping.
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity', '=')
+ ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+ ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
->fieldLanguageCondition($this->fields[0], 'en', '!=', 'delta', 'language');
$this->assertEntityFieldQuery($query, array(
array('test_entity', 1),
@@ -1143,6 +1205,14 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
+ ->fieldLanguageCondition($this->fields[0], 'en', '<>', 'delta', 'language');
+ $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, delta condition unsatisifed).'));
+
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity', '=')
+ ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+ ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
->fieldLanguageCondition($this->fields[0], 'en', '!=', 'delta', 'language');
$this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, delta condition unsatisifed).'));
@@ -1151,6 +1221,14 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
+ ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', 'delta', 'language');
+ $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, language condition unsatisifed).'));
+
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity', '=')
+ ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+ ->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=', 'delta', 'language');
$this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, language condition unsatisifed).'));
@@ -1159,6 +1237,14 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
+ ->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', 'delta', 'language');
+ $this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, both conditions unsatisifed).'));
+
+ $query = new EntityFieldQuery();
+ $query
+ ->entityCondition('entity_type', 'test_entity', '=')
+ ->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
+ ->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '!=', 'delta', 'language');
$this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, both conditions unsatisifed).'));
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index 37555d10b..12e28ff66 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -19,7 +19,7 @@ function system_admin_config_page() {
SELECT m.*, ml.*
FROM {menu_links} ml
INNER JOIN {menu_router} m ON ml.router_path = m.path
- WHERE ml.link_path != 'admin/help' AND menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array('fetch' => PDO::FETCH_ASSOC));
+ WHERE ml.link_path <> 'admin/help' AND menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array('fetch' => PDO::FETCH_ASSOC));
foreach ($result as $item) {
_menu_link_translate($item);
if (!$item['access']) {
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index f01c93f3d..9cc091b67 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -544,7 +544,7 @@ function hook_cron() {
// Long-running operation example, leveraging a queue:
// Fetch feeds from other sites.
- $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh != :never', array(
+ $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < :time AND refresh <> :never', array(
':time' => REQUEST_TIME,
':never' => AGGREGATOR_CLEAR_NEVER,
));
diff --git a/modules/system/system.module b/modules/system/system.module
index 548911dfe..d0a542efb 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2912,7 +2912,7 @@ function system_get_module_admin_tasks($module, $info) {
->condition('ml.hidden', 0, '>=')
->condition('ml.module', 'system')
->condition('m.number_parts', 1, '>')
- ->condition('m.page_callback', 'system_admin_menu_block_page', '!=');
+ ->condition('m.page_callback', 'system_admin_menu_block_page', '<>');
foreach ($query->execute() as $link) {
_menu_link_translate($link);
if ($link['access']) {