1. Install Drupal, ERS and CTools, and enable ERS for the default Article content type.
2. Create an article, leaving the image field blank.
3. Edit the draft and add an image.
4. Attempt to publish the draft immediately.

Result:

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /.../includes/entity.inc).
Notice: Trying to get property of non-object in file_field_presave() (line 220 of /.../modules/file/file.field.inc).
Notice: Undefined property: stdClass::$uri in file_save() (line 573 of /.../includes/file.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /.../includes/entity.inc).
Notice: Trying to get property of non-object in image_field_presave() (line 215 of /.../modules/image/image.field.inc).
Notice: Undefined property: stdClass::$fid in file_usage_add() (line 657 of /.../includes/file.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 19 file_usage.fid may not be NULL: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (?, ?, ?, ?, ?); Array ( [0] => [1] => file [2] => node [3] => 1 [4] => 1 ) in file_usage_add() (line 664 of /.../includes/file.inc).

If I edit the draft, the image field is empty in the edit form. If I then save it (without the image), I can subsequently publish it without errors. If I attempt to add the image again, the errors return.

Comments

john morahan’s picture

Status: Active » Closed (duplicate)

Never mind, it's a core bug.

john morahan’s picture

Status: Closed (duplicate) » Active

Hmm maybe it's not. I assumed this because the problem remained after I disabled ERS, but I can't seem to trigger it without enabling ERS first, even if it's disabled afterwards.

Paul Kim Disney’s picture

So the issue is that node_save ultimately calls file_delete too aggressively. It assumes that node revisions no longer needs an entry in file_usage. Patch coming shortly.

Paul Kim Disney’s picture

Assigned: Unassigned » Paul Kim Disney
merlinofchaos’s picture

No patch yet. Did you mean to attach one?

paul kim consulting’s picture

Version: » 7.x-1.0-beta1

Patch forthcoming...need to get permission from higher ups...

merlinofchaos’s picture

Status: Fixed » Closed (fixed)

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