I've encountered some strange cache rebuilding problems with Entity API modules like Field collections, Profile2, Message and OG. At the end of the cache rebuilt some information (e.g. Profile2 bundle related info) was missing, which is caused by some entity_info_alter hooks that use some other API functions that are based on entity info, although the entity info isn't completely rebuilt yet.
One concrete scenario is described in the EVA issue queue (#1286022: Cache rebuild dependency issues), but I will close the issue there, as it should be fixed in the Entity API.
In order to solve the problem, the way bundles are added to the entity info needs to be re-worked. It should be avoided that API functions with dependencies to entity info are ever used in such a hook.
Comment | File | Size | Author |
---|---|---|---|
#4 | entity_cache_profile2.patch | 1.94 KB | fago |
#4 | entity_cache_og.patch | 1.38 KB | fago |
#3 | entity_cache_entity.patch | 1020 bytes | fago |
Comments
Comment #1
fagoYep, this cache-rebuilding issue seem to pop up again and again. Even if uuid is able to workaround, let's try to break that ugly interdependency and follow core by avoiding the entity-info-alter hack and don't use entity_load() for getting bundle entities. E.g. core uses taxonomy_vocabulary_get_names() in taxonomy_entity_info() to bypass this issue. Bypassing entity-load() is not ideal and a hack too, but at least we can do a way with that inter/self-dependency causing weird issues.
As clean solution I think we should do hook_entity_bundle_info() as proposed in #1092192-24: Using hook_entity_info_alter to add the bundles prevents some modules from altering entities. But that's of course not on the table for d7.
However, in order for that to work with exportables we need to get #1267070: Lazy-rebuilding the defaults for exported entities might not be desirable in first. Given that, exportables should be synced already to the database when the cache is rebuilt during module installation (needs verification).
Then, once this works all the modules (Field collections, Profile2, Message and OG) need to be updated to follow that. Field-collection really is a separate issue though, as it makes use of field_info_field(), but we should be able to trigger entity-info-rebuilding there by fixing it to use field_read_fields().
Comment #2
fagoadding tag
Comment #3
fagook, here is a patch which remove the work-a-round from the entity api.
I don't think there is a hurry to commit this patch though, first modules that use bundle-entities like profile2, og and message should adapt.
Comment #4
fagoattached are patches for profile2 and og.
Comment #6
amitaibu@fago,
So I can already commit this to OG/ Message, or is the patch in #3 needed first?
Comment #7
fagoCommitting the patches now is fine, I've just committed the profile2 patch.
Committing #3 not now does no harm, moreover it requires all used contrib modules to be fixed. So let's postpone it for a while and make sure we fix all the contrib modules now.
Comment #8
fagoThanks Amitaibu for fixing og and message.
I've just fixed field-collection, see
http://drupalcode.org/project/field_collection.git/commit/a2214e9
Comment #9
fagoAlso fixed the testing module, the docs and created a change notification.
Let's commit #3 once beta11 is shipped.
Comment #10
zhangtaihao CreditAttribution: zhangtaihao commentedMight be worth keeping in mind that the hook documentation could be updated to highlight this issue.
After this has been rolled out, of course.
Comment #11
Simon Georges CreditAttribution: Simon Georges commentedIs there still a need for this patch?
Comment #12
tim.plunkettWhat modules are we still waiting on?
Comment #13
Bert Bastiaan CreditAttribution: Bert Bastiaan commented#4: entity_cache_profile2.patch queued for re-testing.
Comment #14
hkirsman CreditAttribution: hkirsman commentedCan this be related to realname module bug where after clearing the cache, list of all tokens are gone under realname admin page?
Comment #15
fagook, there was plenty of time for the releases of the modules to ship. So I've committed #3.