Problem/Motivation

When batch deleting revisions, it seems that some of the old revisions reference files in fields that no longer exist.
Regardless of the circumstances that lead to the broken state, deleting an entity with a file field should succeed even if the referenced file isn't found.

Proposed resolution

When the file id isn't available, assume that the reference is broken or the file has been deleted.

Remaining tasks

Patch attached, needs review and input.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Partial stack trace:

exception 'PDOException' with message 'SQLSTATE[23000]: Integrity        [error]
constraint violation: 1062 Duplicate entry '' for key 'uri'' in
/docroot/includes/database/database.inc:2227
Stack trace:
#0
/docroot/includes/database/database.inc(2227):
PDOStatement->execute(Array)
#1
/docroot/includes/database/database.inc(697):
DatabaseStatementBase->execute(Array, Array)
#2
/docroot/includes/database/mysql/query.inc(36):
DatabaseConnection->query('INSERT INTO {fi...', Array, Array)
#3 /docroot/includes/common.inc(7383):
InsertQuery_mysql->execute()
#4 /docroot/includes/file.inc(616):
drupal_write_record('file_managed', Object(stdClass))
#5
/docroot/modules/file/file.field.inc(371):
file_save(Object(stdClass))
#6
/docroot/modules/file/file.field.inc(328):
file_field_delete_file(NULL, Array, 'node', '11111111')
#7
/docroot/modules/image/image.field.inc(271):
file_field_delete_revision('node', Object(stdClass), Array, Array,
'und', Array)
#8
/docroot/modules/field/field.attach.inc(209):
image_field_delete_revision('node', Object(stdClass), Array, Array,
'und', Array, NULL, NULL)
#9
/home/ubuntu/vicuni/build/docroot/modules/field/field.attach.inc(1083):
_field_invoke('delete_revision', 'node', Object(stdClass))
#10 /docroot/modules/node/node.module(1310):
field_attach_delete_revision('node', Object(stdClass))
CommentFileSizeAuthor
drupal-file_delete_ignore_invalid-0.patch894 byteszeyus

Comments

zeyus created an issue. See original summary.

zeyus’s picture

Status: Active » Closed (won't fix)