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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

steven.wichers’s picture

plach’s picture

Thanks for the patch. I'd rather ensure that entities with an empty $id are not static cached.

amitaibu’s picture

Status: Needs work » Needs review

Coming 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

Status: Needs review » Needs work

The last submitted patch, bulk-presave-calls-fail-after-first-node-1613514.patch, failed testing.

amitaibu’s picture

Status: Needs work » Needs review
FileSize
475 bytes

Sorry, actually patch didn't apply.

plach’s picture

Status: Needs review » Fixed

Committed and pushed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Forgot to mention when this occurs.

  • Commit 61fa65f on 7.x-1.x, workbench authored by steven.wichers, committed by plach:
    Issue #1613514 by steven.wichers, Amitaibu: Fixed Importing nodes in...