When trying to upload a file I get this:
Error message
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'public://2012/04/04//cousin_1.jpg' for key 'uri': INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize, status, timestamp, type, origname) 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, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => cousin_1.jpg [:db_insert_placeholder_2] => public://2012/04/04//cousin_1.jpg [:db_insert_placeholder_3] => image/jpeg [:db_insert_placeholder_4] => 2390372 [:db_insert_placeholder_5] => 1 [:db_insert_placeholder_6] => 1333577537 [:db_insert_placeholder_7] => image [:db_insert_placeholder_8] => cousin_1.jpg ) in drupal_write_record() (line 6980 of /Users/gknaddison/Sites/sports/docroot/includes/common.inc).
If I disable fe_paths the problem goes away.
The problem is apparent at file/add using plupload OR via node/add/TYPE using an image and the media selector widget.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1515728_duplicate_key_shutdown_recursion_multiprocessing.patch | 3.27 KB | greggles |
Comments
Comment #1
dave reidI wonder if this is a problem because file_move() calls file_save() itself.
Comment #2
dave reidMaybe it would be beneficial to have the file directory move be processed in using a queue or drupal_register_shutdown_function() that runs at the end of the request.
Comment #3
gregglesok, I've begun work on the shutdown function idea. A queue could make sense as well, but I worry that we would need something to process the queue and having images move after 5 minutes (e.g. if we process on cron) could be a problem, right? Like if someone creates a node and has the img src point at one place then 4 minutes later on cron the image moves and the img is now broken.
Comment #4
gregglesI was consistently running into duplicate key problems as described in the OP. To solve that and based on Dave's suggestion I:
* Made the $processed an array of orignames that have been processed so we only process a file once.
* Moved the moving to a shutdown function
The only weird change in here is:
That seems to be necessary to remove an extra forward slash on the end.
I also didn't understand this line ($paths variable is never used) so I removed it:
Comment #5
szantog commentedHmm.. I applied the patch manually, but I get 500 error, when upload and image. The new diff against the last commit is:
I search, what the problem is, but I've never used drupal_register_shutdown.
Comment #6
szantog commentedMy fail, wrong manual apply, it seems to work good. Commited.
Comment #8
ultimikeIt appears that the use of the
drupal_register_shutdown_function()is preventing a bunch of the manual image cropping modules from working properly. While the use of thedrupal_register_shutdown_function()makes sense, I'm trying to determine if there's a workaround for manual image cropping modules.I've outlined the issues here: http://drupal.org/node/1647598
I don't think this is an issue with the FE Paths code, I'm just hoping to leverage some expertise to figure out how manual image cropping modules can play nicely with FE Paths.
Thanks in advance,
-mike