summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-22 00:49:13 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-22 00:49:13 +0000
commitcc421475b7313b59b32ca7aa68c5a533f1ffcea8 (patch)
treef0f7f912afccf4b5fdf0907b01b17b69961b2b0b
parent774710328b85c3d9be21846a53bcce674861d941 (diff)
downloadbrdo-cc421475b7313b59b32ca7aa68c5a533f1ffcea8.tar.gz
brdo-cc421475b7313b59b32ca7aa68c5a533f1ffcea8.tar.bz2
- Patch #603236 by bjaspan, catch: add count facility to field_attach_query(). Was ready before code freeze.
-rw-r--r--modules/field/field.api.php23
-rw-r--r--modules/field/field.attach.inc67
-rw-r--r--modules/field/field.crud.inc2
-rw-r--r--modules/field/field.module2
-rw-r--r--modules/field/field.test55
-rw-r--r--modules/field/modules/field_sql_storage/field_sql_storage.module39
-rw-r--r--modules/file/file.module2
-rw-r--r--modules/taxonomy/taxonomy.module2
8 files changed, 104 insertions, 88 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index 3728ba226..db37d8758 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -1064,15 +1064,8 @@ function hook_field_attach_pre_update($obj_type, $object, &$skip_fields) {
* A storage module that doesn't support querying a given column should raise
* a FieldQueryException. Incompatibilities should be mentioned on the module
* project page.
- * @param $count
- * See field_attach_query().
- * @param $cursor
- * See field_attach_query().
- * @param $age
- * - FIELD_LOAD_CURRENT: query the most recent revisions for all
- * objects. The results will be keyed by object type and object id.
- * - FIELD_LOAD_REVISION: query all revisions. The results will be keyed by
- * object type and object revision id.
+ * @param $options
+ * See field_attach_query(). All option keys are guaranteed to be specified.
* @param $skip_field
* Boolean, always coming as FALSE.
* @return
@@ -1080,7 +1073,7 @@ function hook_field_attach_pre_update($obj_type, $object, &$skip_fields) {
* The $skip_field parameter should be set to TRUE if the query has been
* handled.
*/
-function hook_field_attach_pre_query($field_name, $conditions, $count, &$cursor = NULL, $age, &$skip_field) {
+function hook_field_attach_pre_query($field_name, $conditions, $options, &$skip_field) {
}
/**
@@ -1331,16 +1324,12 @@ function hook_field_storage_delete_revision($obj_type, $object, $fields) {
* A storage module that doesn't support querying a given column should raise
* a FieldQueryException. Incompatibilities should be mentioned on the module
* project page.
- * @param $count
- * See field_attach_query().
- * @param $cursor
- * See field_attach_query().
- * @param $age
- * See field_attach_query().
+ * @param $options
+ * See field_attach_query(). All option keys are guaranteed to be specified.
* @return
* See field_attach_query().
*/
-function hook_field_storage_query($field_name, $conditions, $count, &$cursor = NULL, $age) {
+function hook_field_storage_query($field_name, $conditions, $options) {
}
/**
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index 3630ea40d..c01d64bb1 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -1026,26 +1026,28 @@ function field_attach_delete_revision($obj_type, $object) {
* array('value', 12, '>'),
* );
* @endcode
- * @param $count
- * The number of results that is requested. This is only a
+ * @param $options
+ * An associative array of additional options:
+ * - limit: The number of results that is requested. This is only a
* hint to the storage engine(s); callers should be prepared to
* handle fewer or more results. Specify FIELD_QUERY_NO_LIMIT to retrieve
- * all available objects. This parameter has no default value so
+ * all available objects. This option has a default value of 0 so
* callers must make an explicit choice to potentially retrieve an
* enormous result set.
- * @param &$cursor
- * An opaque cursor that allows a caller to iterate through multiple
- * result sets. On the first call, pass 0; the correct value to pass
- * on the next call will be written into $cursor on return. When
- * there is no more query data available, $cursor will be filled in
- * with FIELD_QUERY_COMPLETE. If $cursor is passed as NULL,
- * the first result set is returned and no next cursor is returned.
- * @param $age
- * Internal use only. Use field_attach_query_revisions() instead of passing
- * FIELD_LOAD_REVISION.
- * - FIELD_LOAD_CURRENT (default): query the most recent revisions for all
+ * - cursor: A reference to an opaque cursor that allows a caller to
+ * iterate through multiple result sets. On the first call, pass 0;
+ * the correct value to pass on the next call will be written into
+ * the value on return. When there is no more query data available,
+ * the value will be filled in with FIELD_QUERY_COMPLETE. If cursor
+ * is passed as NULL, the first result set is returned and no next
+ * cursor is returned.
+ * - count: If TRUE, return a single count of all matching objects;
+ * limit and cursor are ignored.
+ * - age: Internal use only. Use field_attach_query_revisions()
+ * instead of passing FIELD_LOAD_REVISION.
+ * - FIELD_LOAD_CURRENT (default): query the most recent revisions for all
* objects. The results will be keyed by object type and object id.
- * - FIELD_LOAD_REVISION: query all revisions. The results will be keyed by
+ * - FIELD_LOAD_REVISION: query all revisions. The results will be keyed by
* object type and object revision id.
* @return
* An array keyed by object type (e.g. 'node', 'user'...), then by object id
@@ -1056,17 +1058,22 @@ function field_attach_delete_revision($obj_type, $object) {
* Throws a FieldQueryException if the field's storage doesn't support the
* specified conditions.
*/
-function field_attach_query($field_id, $conditions, $count, &$cursor = NULL, $age = FIELD_LOAD_CURRENT) {
- if (!isset($cursor)) {
- $cursor = 0;
- }
+function field_attach_query($field_id, $conditions, $options = array()) {
+ // Merge in default options.
+ $default_options = array(
+ 'limit' => 0,
+ 'cursor' => 0,
+ 'count' => FALSE,
+ 'age' => FIELD_LOAD_CURRENT,
+ );
+ $options += $default_options;
// Give a chance to 3rd party modules that bypass the storage engine to
// handle the query.
$skip_field = FALSE;
foreach (module_implements('field_attach_pre_query') as $module) {
$function = $module . '_field_attach_pre_query';
- $results = $function($field_id, $conditions, $count, $cursor, $age, $skip_field);
+ $results = $function($field_id, $conditions, $options, $skip_field);
// Stop as soon as a module claims it handled the query.
if ($skip_field) {
break;
@@ -1076,7 +1083,7 @@ function field_attach_query($field_id, $conditions, $count, &$cursor = NULL, $ag
if (!$skip_field) {
$field = field_info_field_by_id($field_id);
$function = $field['storage']['module'] . '_field_storage_query';
- $results = $function($field_id, $conditions, $count, $cursor, $age);
+ $results = $function($field_id, $conditions, $options);
}
return $results;
@@ -1091,22 +1098,14 @@ function field_attach_query($field_id, $conditions, $count, &$cursor = NULL, $ag
* The id of the field to query.
* @param $conditions
* See field_attach_query().
- * @param $count
- * The number of results that is requested. This is only a
- * hint to the storage engine(s); callers should be prepared to
- * handle fewer or more results. Specify FIELD_QUERY_NO_LIMIT to retrieve
- * all available objects. This parameter has no default value so
- * callers must make an explicit choice to potentially retrieve an
- * enormous result set.
- * @param &$cursor
- * An opaque cursor that allows a caller to iterate through multiple
- * result sets. On the first call, pass 0; the correct value to pass
- * on the next call will be written into $cursor on return.
+ * @param $options
+ * An associative array of additional options. See field_attach_query().
* @return
* See field_attach_query().
*/
-function field_attach_query_revisions($field_id, $conditions, $count, &$cursor = NULL) {
- return field_attach_query($field_id, $conditions, $count, $cursor, FIELD_LOAD_REVISION);
+function field_attach_query_revisions($field_id, $conditions, $options = array()) {
+ $options['age'] = FIELD_LOAD_REVISION;
+ return field_attach_query($field_id, $conditions, $options);
}
/**
diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc
index 68bcd06ca..e2832f37f 100644
--- a/modules/field/field.crud.inc
+++ b/modules/field/field.crud.inc
@@ -965,7 +965,7 @@ function field_purge_batch($batch_size) {
$field = field_info_field_by_id($instance['field_id']);
// Retrieve some pseudo-objects.
- $obj_types = field_attach_query($instance['field_id'], array(array('bundle', $instance['bundle']), array('deleted', 1)), $batch_size);
+ $obj_types = field_attach_query($instance['field_id'], array(array('bundle', $instance['bundle']), array('deleted', 1)), array('limit' => $batch_size));
if (count($obj_types) > 0) {
// Field data for the instance still exists.
diff --git a/modules/field/field.module b/modules/field/field.module
index 5781ddaab..1b9e23b4c 100644
--- a/modules/field/field.module
+++ b/modules/field/field.module
@@ -615,7 +615,7 @@ function field_view_field($obj_type, $object, $field, $instance, $build_mode = '
* TRUE if the field has data for any object; FALSE otherwise.
*/
function field_has_data($field) {
- $results = field_attach_query($field['id'], array(), 1);
+ $results = field_attach_query($field['id'], array(), array('limit' => 1));
return !empty($results);
}
diff --git a/modules/field/field.test b/modules/field/field.test
index 49f763bfa..7abdc5e4c 100644
--- a/modules/field/field.test
+++ b/modules/field/field.test
@@ -605,6 +605,10 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
$instance2['object_type'] = 'test_cacheable_entity';
field_create_instance($instance2);
+ // Unconditional count query returns 0.
+ $count = field_attach_query($this->field_id, array(), array('count' => TRUE));
+ $this->assertEqual($count, 0, t('With no objects, count query returns 0.'));
+
// Create two test objects, using two different types and bundles.
$entity_types = array(1 => 'test_entity', 2 => 'test_cacheable_entity');
$entities = array(1 => field_test_create_stub_entity(1, 1, 'test_bundle'), 2 => field_test_create_stub_entity(2, 2, 'test_bundle_1'));
@@ -620,6 +624,10 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
}
field_attach_insert($entity_types[1], $entities[1]);
+ // Unconditional count query returns 1.
+ $count = field_attach_query($this->field_id, array(), array('count' => TRUE));
+ $this->assertEqual($count, 1, t('With one object, count query returns @count.', array('@count' => $count)));
+
// Create second test object, sharing a value with the first one.
$common_value = $values[$cardinality - 1];
$entities[2]->{$this->field_name} = array($langcode => array(array('value' => $common_value)));
@@ -628,8 +636,11 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
// Query on the object's values.
for ($delta = 0; $delta < $cardinality; $delta++) {
$conditions = array(array('value', $values[$delta]));
- $result = field_attach_query($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_types[1]][1]), t('Query on value %delta returns the object', array('%delta' => $delta)));
+
+ $count = field_attach_query($this->field_id, $conditions, array('count' => TRUE));
+ $this->assertEqual($count, ($values[$delta] == $common_value) ? 2 : 1, t('Count query on value %delta counts %count objects', array('%delta' => $delta, '%count' => $count)));
}
// Query on a value that is not in the object.
@@ -637,31 +648,41 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
$different_value = mt_rand(1, 127);
} while (in_array($different_value, $values));
$conditions = array(array('value', $different_value));
- $result = field_attach_query($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertFalse(isset($result[$entity_types[1]][1]), t("Query on a value that is not in the object doesn't return the object"));
+ $count = field_attach_query($this->field_id, $conditions, array('count' => TRUE));
+ $this->assertEqual($count, 0, t("Count query on a value that is not in the object doesn't count the object"));
// Query on the value shared by both objects, and discriminate using
// additional conditions.
$conditions = array(array('value', $common_value));
- $result = field_attach_query($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_types[1]][1]) && isset($result[$entity_types[2]][2]), t('Query on a value common to both objects returns both objects'));
+ $count = field_attach_query($this->field_id, $conditions, array('count' => TRUE));
+ $this->assertEqual($count, 2, t('Count query on a value common to both objects counts both objects'));
$conditions = array(array('type', $entity_types[1]), array('value', $common_value));
- $result = field_attach_query($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_types[1]][1]) && !isset($result[$entity_types[2]][2]), t("Query on a value common to both objects and a 'type' condition only returns the relevant object"));
+ $count = field_attach_query($this->field_id, $conditions, array('count' => TRUE));
+ $this->assertEqual($count, 1, t("Count query on a value common to both objects and a 'type' condition only returns the relevant object"));
$conditions = array(array('bundle', $entities[1]->fttype), array('value', $common_value));
- $result = field_attach_query($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_types[1]][1]) && !isset($result[$entity_types[2]][2]), t("Query on a value common to both objects and a 'bundle' condition only returns the relevant object"));
+ $count = field_attach_query($this->field_id, $conditions, array('count' => TRUE));
+ $this->assertEqual($count, 1, t("Count query on a value common to both objects and a 'bundle' condition only counts the relevant object"));
$conditions = array(array('entity_id', $entities[1]->ftid), array('value', $common_value));
- $result = field_attach_query($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_types[1]][1]) && !isset($result[$entity_types[2]][2]), t("Query on a value common to both objects and an 'entity_id' condition only returns the relevant object"));
+ $count = field_attach_query($this->field_id, $conditions, array('count' => TRUE));
+ $this->assertEqual($count, 1, t("Count query on a value common to both objects and an 'entity_id' condition only counts the relevant object"));
// Test result format.
$conditions = array(array('value', $values[0]));
- $result = field_attach_query($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$expected = array(
$entity_types[1] => array(
$entities[1]->ftid => field_test_create_stub_entity($entities[1]->ftid, $entities[1]->ftvid),
@@ -694,7 +715,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
// back the right ones.
$cursor = 0;
foreach (array(1 => 1, 3 => 3, 5 => 5, 8 => 8, 13 => 3) as $count => $expect) {
- $found = field_attach_query($this->field_id, array(array('bundle', 'offset_bundle')), $count, $cursor);
+ $found = field_attach_query($this->field_id, array(array('bundle', 'offset_bundle')), array('limit' => $count, 'cursor' => &$cursor));
if (isset($found['test_entity'])) {
$this->assertEqual(count($found['test_entity']), $expect, t('Requested @count, expected @expect, got @found, cursor @cursor', array('@count' => $count, '@expect' => $expect, '@found' => count($found['test_entity']), '@cursor' => $cursor)));
foreach ($found['test_entity'] as $id => $entity) {
@@ -738,7 +759,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
// Query on the object's values.
for ($delta = 0; $delta < $cardinality; $delta++) {
$conditions = array(array('value', $values[$delta]));
- $result = field_attach_query_revisions($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query_revisions($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_type][1]), t('Query on value %delta returns the object', array('%delta' => $delta)));
}
@@ -747,23 +768,23 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase {
$different_value = mt_rand(1, 127);
} while (in_array($different_value, $values));
$conditions = array(array('value', $different_value));
- $result = field_attach_query_revisions($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query_revisions($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertFalse(isset($result[$entity_type][1]), t("Query on a value that is not in the object doesn't return the object"));
// Query on the value shared by both objects, and discriminate using
// additional conditions.
$conditions = array(array('value', $common_value));
- $result = field_attach_query_revisions($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query_revisions($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_type][1]) && isset($result[$entity_type][2]), t('Query on a value common to both objects returns both objects'));
$conditions = array(array('revision_id', $entities[1]->ftvid), array('value', $common_value));
- $result = field_attach_query_revisions($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query_revisions($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(isset($result[$entity_type][1]) && !isset($result[$entity_type][2]), t("Query on a value common to both objects and a 'revision_id' condition only returns the relevant object"));
// Test FIELD_QUERY_RETURN_IDS result format.
$conditions = array(array('value', $values[0]));
- $result = field_attach_query_revisions($this->field_id, $conditions, FIELD_QUERY_NO_LIMIT);
+ $result = field_attach_query_revisions($this->field_id, $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
$expected = array(
$entity_type => array(
$entities[1]->ftid => field_test_create_stub_entity($entities[1]->ftid, $entities[1]->ftvid),
@@ -2579,7 +2600,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase {
$field = reset($this->fields);
// There are 10 objects of this bundle.
- $found = field_attach_query($field['id'], array(array('bundle', $bundle)), FIELD_QUERY_NO_LIMIT);
+ $found = field_attach_query($field['id'], array(array('bundle', $bundle)), array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertEqual(count($found['test_entity']), 10, 'Correct number of objects found before deleting');
// Delete the instance.
@@ -2592,12 +2613,12 @@ class FieldBulkDeleteTestCase extends FieldTestCase {
$this->assertEqual($instances[0]['bundle'], $bundle, 'The deleted instance is for the correct bundle');
// There are 0 objects of this bundle with non-deleted data.
- $found = field_attach_query($field['id'], array(array('bundle', $bundle)), FIELD_QUERY_NO_LIMIT);
+ $found = field_attach_query($field['id'], array(array('bundle', $bundle)), array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertTrue(!isset($found['test_entity']), 'No objects found after deleting');
// There are 10 objects of this bundle when deleted fields are allowed, and
// their values are correct.
- $found = field_attach_query($field['id'], array(array('bundle', $bundle), array('deleted', 1)), FIELD_QUERY_NO_LIMIT);
+ $found = field_attach_query($field['id'], array(array('bundle', $bundle), array('deleted', 1)), array('limit' => FIELD_QUERY_NO_LIMIT));
field_attach_load($this->entity_type, $found[$this->entity_type], FIELD_LOAD_CURRENT, array('field_id' => $field['id'], 'deleted' => 1));
$this->assertEqual(count($found['test_entity']), 10, 'Correct number of objects found after deleting');
foreach ($found['test_entity'] as $id => $obj) {
@@ -2629,7 +2650,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase {
field_purge_batch($batch_size);
// There are $count deleted objects left.
- $found = field_attach_query($field['id'], array(array('bundle', $bundle), array('deleted', 1)), FIELD_QUERY_NO_LIMIT);
+ $found = field_attach_query($field['id'], array(array('bundle', $bundle), array('deleted', 1)), array('limit' => FIELD_QUERY_NO_LIMIT));
$this->assertEqual($count ? count($found['test_entity']) : count($found), $count, 'Correct number of objects found after purging 2');
}
diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.module b/modules/field/modules/field_sql_storage/field_sql_storage.module
index 76caa2634..ae3fd73d6 100644
--- a/modules/field/modules/field_sql_storage/field_sql_storage.module
+++ b/modules/field/modules/field_sql_storage/field_sql_storage.module
@@ -469,8 +469,8 @@ function field_sql_storage_field_storage_purge($obj_type, $object, $field, $inst
/**
* Implement hook_field_storage_query().
*/
-function field_sql_storage_field_storage_query($field_id, $conditions, $count, &$cursor, $age) {
- $load_current = $age == FIELD_LOAD_CURRENT;
+function field_sql_storage_field_storage_query($field_id, $conditions, $options) {
+ $load_current = $options['age'] == FIELD_LOAD_CURRENT;
$field = field_info_field_by_id($field_id);
$field_name = $field['field_name'];
@@ -481,14 +481,6 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $count, &
$query = db_select($table, 't');
$query->join('field_config_entity_type', 'e', 't.etid = e.etid');
- $query
- ->fields('t', array('bundle', 'entity_id', 'revision_id'))
- ->fields('e', array('type'))
- // We need to ensure objects arrive in a consistent order for the
- // range() operation to work.
- ->orderBy('t.etid')
- ->orderBy('t.entity_id');
-
// Add conditions.
foreach ($conditions as $condition) {
// A condition is either a (column, value, operator) triple, or a
@@ -542,6 +534,21 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $count, &
$query->condition('deleted', 0);
}
+ // For a count query, return the count now.
+ if ($options['count']) {
+ $query->addExpression('COUNT(DISTINCT e.type,t.entity_id,t.revision_id)');
+ return $query->execute()->fetchField();
+ }
+
+ // For a data query, add fields.
+ $query
+ ->fields('t', array('bundle', 'entity_id', 'revision_id'))
+ ->fields('e', array('type'))
+ // We need to ensure objects arrive in a consistent order for the
+ // range() operation to work.
+ ->orderBy('t.etid')
+ ->orderBy('t.entity_id');
+
// Initialize results array
$return = array();
@@ -551,15 +558,15 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $count, &
// less rows than asked for.
$obj_count = 0;
do {
- if ($count != FIELD_QUERY_NO_LIMIT) {
- $query->range($cursor, $count);
+ if ($options['limit'] != FIELD_QUERY_NO_LIMIT) {
+ $query->range($options['cursor'], $options['limit']);
}
$results = $query->execute();
$row_count = 0;
foreach ($results as $row) {
$row_count++;
- $cursor++;
+ $options['cursor']++;
// If querying all revisions and the entity type has revisions, we need
// to key the results by revision_ids.
$entity_type = field_info_fieldable_types($row->type);
@@ -570,12 +577,12 @@ function field_sql_storage_field_storage_query($field_id, $conditions, $count, &
$obj_count++;
}
}
- } while ($count != FIELD_QUERY_NO_LIMIT && $row_count == $count && $obj_count < $count);
+ } while ($options['limit'] != FIELD_QUERY_NO_LIMIT && $row_count == $options['limit'] && $obj_count < $options['limit']);
// The query is complete when the last batch returns less rows than asked
// for.
- if ($row_count < $count) {
- $cursor = FIELD_QUERY_COMPLETE;
+ if ($row_count < $options['limit']) {
+ $options['cursor'] = FIELD_QUERY_COMPLETE;
}
return $return;
diff --git a/modules/file/file.module b/modules/file/file.module
index fa8330af4..243ae87a3 100644
--- a/modules/file/file.module
+++ b/modules/file/file.module
@@ -921,7 +921,7 @@ function file_get_file_references($file, $field = NULL, $age = FIELD_LOAD_REVISI
if (!isset($references[$field_name])) {
// Get each time this file is used within a field.
$cursor = 0;
- $references[$field_name] = field_attach_query($file_field['id'], array(array('fid', $file->fid)), FIELD_QUERY_NO_LIMIT, $cursor, $age);
+ $references[$field_name] = field_attach_query($file_field['id'], array(array('fid', $file->fid)), array('limit' => FIELD_QUERY_NO_LIMIT, 'cursor' => &$cursor, 'age'=> $age));
}
}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 8a4bbd11c..cf1ef1bc1 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1200,7 +1200,7 @@ function _taxonomy_clean_field_cache($term) {
if ($obj_types) {
$conditions[] = array('type', $obj_types, 'NOT IN');
}
- $results = field_attach_query($field['id'], $conditions, FIELD_QUERY_NO_LIMIT);
+ $results = field_attach_query($field['id'], $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
foreach ($results as $obj_type => $objects) {
foreach (array_keys($objects) as $id) {
$cids[] = "field:$obj_type:$id";