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.
Comment | File | Size | Author |
---|---|---|---|
#6 | entity_info_cache_clear-642612-6.patch | 4.36 KB | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedAnother place: #642614: locale_add_language() should reset entity_info cache
Comment #2
catchSee 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.
Comment #3
yched CreditAttribution: yched commentedFWIW, Field API has field_cache_clear() (field data) and field_info_cache_clear() (field info).
Comment #4
catchentity_info_cache_clear() then?
Comment #5
yched CreditAttribution: yched commentedyay ;-)
Comment #6
yched CreditAttribution: yched commentedPatch.
Comment #7
catchRTBC patch.
(please wait for test bot to come back before commit).
Comment #8
yched CreditAttribution: yched commenteder, fix issue title :-p
Comment #9
yched CreditAttribution: yched commentedand without repeating 'clean'
Comment #10
webchickWhile 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.
Comment #11
webchickComment #12
yched CreditAttribution: yched commentedAdded 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
Comment #13
solotandem CreditAttribution: solotandem commentedyched, 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.
Comment #14
yched CreditAttribution: yched commentedDoh, thanks solotandem, I could indeed have seen that myself :-/