When plupload is enabled, and something goes wrong during file copying/uploading (e.g. corrupted or large images), media attempts to proceed anyway with the half-baked file, and will put a new record in the {file_managed} table with no URI. Since this outcome is not handled, no errors are thrown, except for a watchdog log entry, that the user may not notice:
File temporary://p19fc21br5bkrjg51nrjm8lobr4.tmp (/Applications/MAMP/tmp/php/p19fc21br5bkrjg51nrjm8lobr4.tmp) could not be copied because it does not exist.
Later, if another failure occurs, we will get a PDOException:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize, status, timestamp, type) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => [:db_insert_placeholder_3] => application/octet-stream [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1425260317 [:db_insert_placeholder_7] => default ) in drupal_write_record() (line 7239 of /Users/attila/dev/drupal-7/includes/common.inc).
Comments
Comment #1
attila.fekete CreditAttribution: attila.fekete commentedWrote a patch to avoid inserting such records in the db.
Comment #2
attila.fekete CreditAttribution: attila.fekete commentedComment #3
DamienMcKennaOut of interest, are you running the site on a web cluster, i.e. with multiple web servers running the same site? If so, you might be running into a problem with the file submissions being split across the multiple servers, so the server that gets the final HTTP request only has some of the files. This is common on e.g. Acquia hosting.
Comment #4
TheAllverse CreditAttribution: TheAllverse commentedPlease help. I get a similar message whenever I try and update my theme settings by changing the shortcut icon
and
I'm not sure why it's doing this. Will that patch work for this and if so, how do I apply it? Still new to Drupal.
Comment #5
attila.fekete CreditAttribution: attila.fekete commented@DamienMcKenna yes, and I also thought that the issue comes up when chunks are being splitted across multiple web servers. But the reason I proposed the patch is that I was having the same problem in a different environment (locally as well).
Comment #6
attila.fekete CreditAttribution: attila.fekete commentedMade some changes to the initial patch to display a message about the failure instead of throwing an exception.
Comment #7
attila.fekete CreditAttribution: attila.fekete commentedRe-rolled against latest dev and fixed an issue with messages not being displayed in some cases.
Comment #8
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team