Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#5 | 1613514-title-bulk-save-4.patch | 475 bytes | amitaibu |
#1 | bulk-presave-calls-fail-after-first-node-1613514.patch | 647 bytes | steven.wichers |
Comments
Comment #1
steven.wichers CreditAttribution: 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) CreditAttribution: commentedForgot to mention when this occurs.