diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-03-27 18:41:14 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-03-27 18:41:14 +0000 |
commit | d864fc6363b03662cb904d6117b4e110f16d0158 (patch) | |
tree | 9da0a0eaa167652ed64b98a3d13e22ebbe37e6ec | |
parent | be6d3c8bb601fa53839b6c187b31e883e3334560 (diff) | |
download | brdo-d864fc6363b03662cb904d6117b4e110f16d0158.tar.gz brdo-d864fc6363b03662cb904d6117b4e110f16d0158.tar.bz2 |
- Patch #754686 by yched: rename 'cacheable' property in hook_entity_info().
-rw-r--r-- | includes/common.inc | 6 | ||||
-rw-r--r-- | modules/field/field.attach.inc | 23 | ||||
-rw-r--r-- | modules/field/tests/field_test.entity.inc | 8 | ||||
-rw-r--r-- | modules/node/node.module | 2 | ||||
-rw-r--r-- | modules/system/system.api.php | 9 |
5 files changed, 23 insertions, 25 deletions
diff --git a/includes/common.inc b/includes/common.inc index 06b029a14..f6ad0e7cd 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -6234,11 +6234,11 @@ function entity_get_info($entity_type = NULL) { 'fieldable' => FALSE, 'controller class' => 'DrupalDefaultEntityController', 'static cache' => TRUE, + 'field cache' => TRUE, 'load hook' => $name . '_load', 'bundles' => array(), 'view modes' => array(), 'entity keys' => array(), - 'cacheable' => TRUE, 'translation' => array(), ); $entity_info[$name]['entity keys'] += array( @@ -6287,7 +6287,6 @@ function entity_info_cache_clear() { * 0: primary id of the entity * 1: revision id of the entity, or NULL if $entity_type is not versioned * 2: bundle name of the entity - * 3: whether $entity_type's fields should be cached (TRUE/FALSE) */ function entity_extract_ids($entity_type, $entity) { $info = entity_get_info($entity_type); @@ -6297,8 +6296,7 @@ function entity_extract_ids($entity_type, $entity) { // If no bundle key provided, then we assume a single bundle, named after the // entity type. $bundle = $info['entity keys']['bundle'] ? $entity->{$info['entity keys']['bundle']} : $entity_type; - $cacheable = $info['cacheable']; - return array($id, $vid, $bundle, $cacheable); + return array($id, $vid, $bundle); } /** diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc index f177f535d..0206e4b57 100644 --- a/modules/field/field.attach.inc +++ b/modules/field/field.attach.inc @@ -560,9 +560,9 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $ $options += $default_options; $info = entity_get_info($entity_type); - // Only the most current revision of non-deleted fields for - // cacheable fieldable types can be cached. - $cache_read = $load_current && $info['cacheable'] && empty($options['deleted']); + // Only the most current revision of non-deleted fields for cacheable entity + // types can be cached. + $cache_read = $load_current && $info['field cache'] && empty($options['deleted']); // In addition, do not write to the cache when loading a single field. $cache_write = $cache_read && !isset($options['field_id']); @@ -848,7 +848,7 @@ function field_attach_insert($entity_type, $entity) { _field_invoke_default('insert', $entity_type, $entity); _field_invoke('insert', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // Let any module insert field data before the storage engine, accumulating // saved fields along the way. @@ -881,7 +881,8 @@ function field_attach_insert($entity_type, $entity) { // Let other modules act on inserting the entity. module_invoke_all('field_attach_insert', $entity_type, $entity); - if ($cacheable) { + $entity_info = entity_get_info($entity_type); + if ($entity_info['field cache']) { cache_clear_all("field:$entity_type:$id", 'cache_field'); } } @@ -897,7 +898,7 @@ function field_attach_insert($entity_type, $entity) { function field_attach_update($entity_type, $entity) { _field_invoke('update', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // Let any module update field data before the storage engine, accumulating // saved fields along the way. @@ -934,7 +935,8 @@ function field_attach_update($entity_type, $entity) { // Let other modules act on updating the entity. module_invoke_all('field_attach_update', $entity_type, $entity); - if ($cacheable) { + $entity_info = entity_get_info($entity_type); + if ($entity_info['field cache']) { cache_clear_all("field:$entity_type:$id", 'cache_field'); } } @@ -951,7 +953,7 @@ function field_attach_update($entity_type, $entity) { function field_attach_delete($entity_type, $entity) { _field_invoke('delete', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // Collect the storage backends used by the fields in the entities. $storages = array(); @@ -970,7 +972,8 @@ function field_attach_delete($entity_type, $entity) { // Let other modules act on deleting the entity. module_invoke_all('field_attach_delete', $entity_type, $entity); - if ($cacheable) { + $entity_info = entity_get_info($entity_type); + if ($entity_info['field cache']) { cache_clear_all("field:$entity_type:$id", 'cache_field'); } } @@ -987,7 +990,7 @@ function field_attach_delete($entity_type, $entity) { function field_attach_delete_revision($entity_type, $entity) { _field_invoke('delete_revision', $entity_type, $entity); - list($id, $vid, $bundle, $cacheable) = entity_extract_ids($entity_type, $entity); + list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity); // Collect the storage backends used by the fields in the entities. $storages = array(); diff --git a/modules/field/tests/field_test.entity.inc b/modules/field/tests/field_test.entity.inc index 8c32602ea..fb9130baf 100644 --- a/modules/field/tests/field_test.entity.inc +++ b/modules/field/tests/field_test.entity.inc @@ -23,26 +23,26 @@ function field_test_entity_info() { return array( 'test_entity' => array( 'name' => t('Test Entity'), + 'fieldable' => TRUE, + 'field cache' => FALSE, 'entity keys' => array( 'id' => 'ftid', 'revision' => 'ftvid', 'bundle' => 'fttype', ), - 'cacheable' => FALSE, 'bundles' => $bundles, - 'fieldable' => TRUE, 'view modes' => $test_entity_modes, ), // This entity type doesn't get form handling for now... 'test_cacheable_entity' => array( 'name' => t('Test Entity, cacheable'), + 'fieldable' => TRUE, + 'field cache' => TRUE, 'entity keys' => array( 'id' => 'ftid', 'revision' => 'ftvid', 'bundle' => 'fttype', ), - 'fieldable' => TRUE, - 'cacheable' => TRUE, 'bundles' => $bundles, 'view modes' => $test_entity_modes, ), diff --git a/modules/node/node.module b/modules/node/node.module index 68a7c2f6d..e0e159073 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -191,8 +191,6 @@ function node_entity_info() { 'bundle keys' => array( 'bundle' => 'type', ), - // Node.module handles its own caching. - // 'cacheable' => FALSE, 'bundles' => array(), 'view modes' => array( 'full' => array( diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 3bfa0e4b6..b0f58b1fe 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -64,6 +64,10 @@ function hook_hook_info() { * entity type's base table. * - static cache: (used by DrupalDefaultEntityController) FALSE to disable * static caching of entities during a page request. Defaults to TRUE. + * - field cache: (used by Field API loading and saving of field data) FALSE + * to disable Field API's persistent cache of field data. Only recommended + * if a higher level persistent cache is available for the entity type. + * Defaults to TRUE. * - load hook: The name of the hook which should be invoked by * DrupalDefaultEntityController:attachLoad(), for example 'node_load'. * - uri callback: A function taking an entity as argument and returning the @@ -92,9 +96,6 @@ function hook_hook_info() { * standalone objects. Elements: * - bundle: The name of the property that contains the name of the bundle * object. - * - cacheable: A boolean indicating whether Field API should cache - * loaded fields for each object, reducing the cost of - * field_attach_load(). * - bundles: An array describing all bundles for this object type. * Keys are bundles machine names, as found in the objects' 'bundle' * property (defined in the 'entity keys' entry above). Elements: @@ -139,8 +140,6 @@ function hook_entity_info() { 'bundle keys' => array( 'bundle' => 'type', ), - // Node.module handles its own caching. - // 'cacheable' => FALSE, 'bundles' => array(), 'view modes' => array( 'full' => array( |