This is due to there not being an $id returned from entity_extract_ids when called, and then the $sync static variable winds up reusing the same location for each consecutive call. I noticed this happening during a Feed import run and tracked it down to the presave hook.
Problem code:
$sync = &drupal_static(__FUNCTION__, array());
list($id, , $bundle) = entity_extract_ids($entity_type, $entity);
$langcode = field_valid_language($langcode, FALSE);
// We do not need to perform this more than once.
if (!empty($sync[$entity_type][$id][$langcode][$set])) {
return;
}
Fix:
if (!empty($id) && !empty($sync[$entity_type][$id][$langcode][$set])) {
There may possibly be a better alternative to using $id to build this array.
Comments
Comment #1
steven.wichers commentedComment #2
plachThanks for the patch. I'd rather ensure that entities with an empty $id are not static cached.
Comment #3
amitaibuComing from #1672212: Make sure the node templates are no longer harcoded
> I'd rather ensure that entities with an empty $id are not static cached.
They are not, the static cache is set after the above IF. I think it's RTBC
Comment #5
amitaibuSorry, actually patch didn't apply.
Comment #6
plachCommitted and pushed, thanks.
Comment #7.0
(not verified) commentedForgot to mention when this occurs.