Currently several places in core need to clear the entity_info() cache API: RDF module, field module, system_modules_submit().
#553306-76: Make nodes have no body field by default. Remove deprecated APIs for body field adds a new spot : node_type_save() - but this will probably be the case for every "{entity}_save_bundle()" function.

There is no clean API way of doing this, so you need to know that the entity cache is stored both statically and in an 'entity_info' entry in the 'cache' table:

  drupal_static_reset('entity_get_info');
  cache_clear_all('entity_info', 'cache');

Ugh. I don't think this is where we wanted to be in D7.

CommentFileSizeAuthor
#6 entity_info_cache_clear-642612-6.patch4.36 KByched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

catch’s picture

See also #581626: Use a consistent/clean pattern for using $reset or drupal_static().

I'd probably go for a entity_info_reset_cache() wrapper given current state of HEAD.

yched’s picture

FWIW, Field API has field_cache_clear() (field data) and field_info_cache_clear() (field info).

catch’s picture

entity_info_cache_clear() then?

yched’s picture

yay ;-)

yched’s picture

Status: Active » Needs review
FileSize
4.36 KB

Patch.

catch’s picture

Status: Needs review » Reviewed & tested by the community

RTBC patch.

(please wait for test bot to come back before commit).

yched’s picture

Title: No clean way to entity_info cache » No clean way to clean entity_info cache

er, fix issue title :-p

yched’s picture

Title: No clean way to clean entity_info cache » No clean way to reset entity_info cache

and without repeating 'clean'

webchick’s picture

Issue tags: +Needs documentation

While technically this is an API change, it's something contributed module developers are going to get totally wrong if we don't make a wrapper function for it, I fear, and will cause tons of really hard-to-track-down follow-up bugs. It's non-intuitive to say the least that two function calls would be provided for a simple cache clear. It also meshes with what the field API is doing.

Committed to HEAD. Needs to be documented in the module upgrade guide. Please also add a pointer to the docs in the Coder module issue queue against the "Upgrade Rules" component.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
yched’s picture

Status: Needs work » Fixed

Added this in http://drupal.org/update/modules/6/7:
(side note: I'm not sure of the meaning of the "[X]" in front of list entries at the top of the page. I included one in the new entry :-/)

New entity_info_cache_clear() API function

Issue #642612: No clean way to reset entity_info cache

The entity_get_info() function collects information about the entity types (new D7 concept - see Added hook_entity_load()) present on the site. For performance reasons, this information happens to be both statically and persistently cached.

The entity_info_cache_clear() API function can be used to reset both caches.

+ added a link in coder queue : #643944: New entity_info_cache_clear() API function

solotandem’s picture

yched, the "[X]" indicates the issue has been cross-referenced in the categorical page as mentioned in the annotation note at the top of the update/modules/6/7 page.

I added the issue to the categorical page today.

yched’s picture

Doh, thanks solotandem, I could indeed have seen that myself :-/

Status: Fixed » Closed (fixed)
Issue tags: -Needs documentation

Automatically closed -- issue fixed for 2 weeks with no activity.