Commit d864fc63 authored by Dries's avatar Dries

- Patch #754686 by yched: rename 'cacheable' property in hook_entity_info().

parent be6d3c8b
......@@ -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);
}
/**
......
......@@ -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();
......
......@@ -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,
),
......
......@@ -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(
......
......@@ -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(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment