Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
d864fc63
Commit
d864fc63
authored
Mar 27, 2010
by
Dries
Browse files
- Patch
#754686
by yched: rename 'cacheable' property in hook_entity_info().
parent
be6d3c8b
Changes
5
Hide whitespace changes
Inline
Side-by-side
includes/common.inc
View file @
d864fc63
...
...
@@ -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
);
}
/**
...
...
modules/field/field.attach.inc
View file @
d864fc63
...
...
@@ -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
[
'cach
eabl
e'
]
&&
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
();
...
...
modules/field/tests/field_test.entity.inc
View file @
d864fc63
...
...
@@ -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
,
),
...
...
modules/node/node.module
View file @
d864fc63
...
...
@@ -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
(
...
...
modules/system/system.api.php
View file @
d864fc63
...
...
@@ -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
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment