When create multiple new entities of the same type with different types of bundles as it will more than likely happen with field collections there is conflicts in the caching which results in the fields language being returned as 0.
When entities have been saved the items will not conflict as they will all have unique ids, but when they are new entity_extract_ids() will return as id of 0 for every entity. and this means if you have 2 new entities of different bundles the first will set the cache, but the second will try and use the first cache.
The solution that I have added is to make the bundle as a part of the cache. this will mean that on new entities will be inserted uniquely, but in the case of existing entities it will only add a single additional level which should have no impact on performance other than an additional level of array.
Comment | File | Size | Author |
---|---|---|---|
#8 | field_language-1587874-8.patch | 1.43 KB | james.williams |
patch_commit_70601e386f2d.patch | 1.34 KB | gordon | |
Comments
Comment #1
gordon CreditAttribution: gordon commentedComment #3
gordon CreditAttribution: gordon commentedpatch_commit_70601e386f2d.patch queued for re-testing.
Comment #4
james.williams CreditAttribution: james.williams at ComputerMinds commentedI just ran into this -- I totally agree with gordon and his approach, and the patch looks good and works fine for me.
Comment #5
recrit CreditAttribution: recrit commentedfield_language is broken in general for new entities and revisions. See the related issues.
Comment #6
recrit CreditAttribution: recrit commentedReview patch #5 on #2201251: field_language shouldn't cache display_languages for new entities - This patch handles new entities and revisions. The bundle key for the static cache should not be needed since an existing id would not be able to have multiple bundles, and a new entity should not be cached.
Comment #7
james.williams CreditAttribution: james.williams at ComputerMinds commented@recrit - see #2201251-7: field_language shouldn't cache display_languages for new entities.
Comment #8
james.williams CreditAttribution: james.williams at ComputerMinds commentedNew patch that includes caching by revision IDs too (#2069439: Static cache in field_language() should key by $vid as well as $id).