添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Announcement icon Drupal 7 will officially reach its End of Life on 5 January 2025. This date marks the 14-year anniversary since Drupal 7 was released on 5 January 2011. It is recommended to migrate your site as soon as possible.
Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
file.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Needs issue summary update about tags
Needs backport to D7

After being applied to the 8.x branch, it should be considered for backport to the 7.x branch.
Note: This tag should generally remain even after the backport has been written, approved, and committed.

Needs issue summary update

Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions .

Reporter:
Created:
20 May 2011 at 13:11 UTC
Updated:
24 Jun 2023 at 12:33 UTC
My client is populating nodes with data, and every now and then they get this error:

Notice: Trying to get property of non-object in file_field_presave() (line 221 of /httpdocs/modules/file/file.field.inc).
Notice: Undefined property: stdClass::$uri in file_save() (line 575 of /httpdocs/includes/file.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1305820825 ) in drupal_write_record() (line 6776 of /httpdocs/includes/common.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1305820825 ) in drupal_write_record() (line 6776 of /httpdocs/includes/common.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1305820825 ) in drupal_write_record() (line 6776 of /httpdocs/includes/common.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1305820825 ) in drupal_write_record() (line 6776 of /httpdocs/includes/common.inc).

I've only found reference to the same PDOException and initial notice here:

http://drupal.org/node/924228#comment-4422726

Effectively, it looks like Drupal is trying to save a file, but there's no filename or filesave, so it's failing as a duplicate of the first time this happened (and was stored in the DB).
I think the PDOException is just a symptom, and the real problem is that an invalid file object is being passed along.

I can't be sure whether my client is trying to upload/delete/change a file, or just entering text data into other fields, but this comes up frequently and seemingly at random.

The easiest way to reproduce this error is:

  • Add an image field into a node
  • Create a new node and upload an image to its node
  • Delete the image from the file system (Not through the Drupal UI)
  • Try to upload the same image into another node
  • CommentFileSizeAuthor #167 error database.png 70.29 KB jomarocas #157 error1.png 24.9 KB shakthik92 #141 file-Integrity_constraint_violation-1163740-141.patch 2.89 KB revagomes
    FAILED: [[SimpleTest]]: [MySQL] 59,627 pass(es), 41 fail(s), and 0 exception(s). View
    #137 file-Integrity_constraint_violation-1163740-137.patch 909 bytes revagomes
    FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 86,960 pass(es), 2 fail(s), and 0 exception(s). View
    #134 file-Integrity_constraint_violation-1163740-134.patch 918 bytes revagomes
    FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file-Integrity_constraint_violation-1163740-134.patch. Unable to apply patch. See the log in the details link for more information. View
    #108 file-integrity-violation-fix-both-1163740-108.patch 1.38 KB j0rd
    FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file-integrity-violation-fix-both-1163740-108.patch. Unable to apply patch. See the log in the details link for more information. View
    #107 file-integrity-violation-fix-both-1163740-107.patch 1004 bytes j0rd
    FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file-integrity-violation-fix-both-1163740-107.patch. Unable to apply patch. See the log in the details link for more information. View
    #66 file.field_.inc-1163740.patch 508 bytes kenorb
    FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file.field_.inc-1163740_0.patch. Unable to apply patch. See the log in the details link for more information. View
    #62 file.field_.inc-1163740.patch 534 bytes kenorb
    FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file.field_.inc-1163740.patch. Unable to apply patch. See the log in the details link for more information. View
    #59 file.field_.inc_.patch 520 bytes kenorb
    FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch file.field_.inc_.patch. Unable to apply patch. See the log in the details link for more information. View
    #56 aat-drupal-clean_myaat_services_workexperience_submit_preview--1339162858.xt_.txt.gz 97.43 KB kenorb

    Issue fork drupal-1163740

    Command icon Show commands

    Start within a Git clone of the project using the version control instructions .

    Or, if you do not have SSH keys set up on git.drupalcode.org :

    i having this problem too, when a new user account is created. I have an image field at the user entity.

    Any ideas?