If I upload a file with the same file name twice, I get the following error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'public://webform/testli.xml' for key 'uri': INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize, status, timestamp) 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); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => testli.xml [:db_insert_placeholder_2] => public://webform/testli.xml [:db_insert_placeholder_3] => application/xml [:db_insert_placeholder_4] => 765 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 1299082209 ) in drupal_write_record() (Zeile 6776 von /var/www/drupal7/includes/common.inc).
Shall I tag this issue with 'common'? Or could Drupal Core's 'common.inc' even be the culprit in this case? Thank you for this great module and the maintenance.
Comments
Comment #1
Blooniverse commented... this happens, BTW, even if delete the previously uploaded file first!
Comment #2
Blooniverse commented... still existing in v3.9! Sorry.
Comment #3
Blooniverse commentedComment #4
quicksketchThanks phi. I haven't actually attempted to fix this problem yet so I'm sure it still exists.
Comment #5
10basetom commentedI also got a PDOException: SQLSTATE[23000] error after creating a new post that has an image and then trying to delete the post. Here is the full error message:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '8WlNJcpA6fK06xIUM3cwoNA8EOqs2hwuwPvKv23CbCU' for key 'hash': INSERT INTO {redirect} (hash, type, uid, source, source_options, redirect, redirect_options, language, status_code, count, last_used) 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, :db_insert_placeholder_9, :db_insert_placeholder_10); Array ( [:db_insert_placeholder_0] => 8WlNJcpA6fK06xIUM3cwoNA8EOqs2hwuwPvKv23CbCU [:db_insert_placeholder_1] => redirect [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => a:0:{} [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => a:0:{} [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => 0 [:db_insert_placeholder_9] => 0 [:db_insert_placeholder_10] => 0 ) in drupal_write_record() (line 6776 of ... common.inc).
Comment #6
Blooniverse commentedWhat a pitty, I think I should have tested this on a real test site first. Since the deactivation of 'Webform Validation 7.x-1.0-rc1 (2010-Dec-31)' the double upload of the same file (with the same file name) works -- this on a Drupal7 dev site with about ~90 contrib modules running at the same time.
What I don't get is: Where is the 'bug link/relation' to 'Webform Validation'? From my point of view such a link/relation seems to be evident -- see #1085666: Webform submission triggered too early -- when using pagebreaks as well ! Correct me please, if I should be wrong.
Comment #7
rbonja1 commentedis there any solution for this, i am getting this error when trying to add something in the views module
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'diary_update' for key 2: INSERT INTO {views_view} (name, description, tag, base_table, human_name, core) 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); Array ( [:db_insert_placeholder_0] => diary_update [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => default [:db_insert_placeholder_3] => node [:db_insert_placeholder_4] => diary update [:db_insert_placeholder_5] => 7 ) in views_db_object->save_row() (line 1830 of /sites/all/modules/views/includes/view.inc).
Comment #8
Blooniverse commented... I've briefly checked again & come to the conclusion that the bug must relate to the stale records in the table 'file_managed'! If one presses the 'empty/flush' button resp. tab in Webform, then this table should be cleaned out properly, orientating on the field/column 'fid'. Right?
BTW, I want to correct my words in comment#6: After deleting uploaded files manually from the real folder (in the file system), this error occurs again in my case. My comment#6 related to a double file upload without deleting files manually first!
Comment #9
quicksketchI think that's actually the source of the entire problem. You do not have this problem if you don't manually delete the files (at least in my testing). Simply put you can never "manually" just delete a file from disk. What's happening here is that Webform is saving the file to disk and inserting a database record in the file_managed table. When you delete the file from disk, Webform will save the file to the same location again and then encounter a problem when inserting a record into the "file_managed" table, since a record already exists for that exact same file name. Your option are either A) Delete the file manually both on disk and in the database table or B) Just wait 6 hours and if you've set up cron correctly, it will delete the file automatically for you if it is still marked "temporary" in the file_managed table.
For everyone else having similar errors in the "diary_update" (#7) or "redirect" (#5) tables, please file issues in the corresponding modules.
If you can provide instructions on how to reproduce this problem on a clean install without manually deleting files from disk I'll have a look at it, but this seems like a self-inflicted problem.
Comment #10
AmyMarie commentedFor some reason... I don't think that you told us how to fix this problem.. I have no "diary_update" or "redirect" table and my "file_managed" table is empty and I still get this problem. I am running Drupal 7.4 and do not understand how to fix this or what table should be emptied out? Please help...
thank you,
Amy
Comment #11
ninonoscar commentedI join Amy marie, i have exactly the same problems, and a little help would be welcome.
thank you
PS: post 6 was the solution for me.
But i haven't anymore a page break in my webform...
Thanks a lot for the contributors, and posters
Comment #12
quicksketchHow can your "file_managed" table be empty if that's where you're getting the error?
This error means that you have two records in that table that are conflicting because they have the same keys. If you've manually deleted files from disk, you also have to remove the records from the file_managed table. You'd also have to delete the submission record from the webform_submitted_data table.
Comment #13
Blooniverse commentedHey @quicksketch! I've had a ~5 month break from Drupal7. Need to catch up a bit. After briefly reading this thread, it seems clear to me that what I mentioned in comment#8 ("Webform's flushing tab should flush everything out") is quite correct: A proper flush is a proper flush, or not? :)
Comment #14
artworker commented@rbonja1
I have the same error in views also:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'tweet_test' for key 'name': INSERT INTO {views_view} (name, description, tag, base_table, human_name, core) 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); Array ( [:db_insert_placeholder_0] => tweet_test [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => default [:db_insert_placeholder_3] => twitter [:db_insert_placeholder_4] => tweet test [:db_insert_placeholder_5] => 7 ) in views_db_object->save_row() (line 1994 of /home/www/wayneblake.com/sites/all/modules/views/includes/view.inc).
Did you manage to come up with a solution?
I have a D7.8 site
Comment #15
quicksketchWebform already deletes all files that are uploaded to all submissions when you clear an entire node's submissions.
Gah! That has *nothing to do* with Webform! It's a *Views* error: "INSERT INTO {views_view}"
Considering we've now been hijacked by redirect, diary_update, and now views, all the while I can't reproduce the problem, I'm closing this issue. Please do not reopen, file a new issue if you're experiencing a problem when uploading the same file twice.
Comment #16
Blooniverse commented@quicksketch#15: Thanks for your reply! Hm ... as much as I remember, Webform does NOT flush the table 'file_managed'! Am I really wrong with that memory in my head? I obviously combine 'in my head' with 'memory', not 'wrong' ;D Oh, reflecting too much. Sorry. Must be my state at the moment.
Comment #17
coderintherye commentedPretty sure this problem still exists, though going to wait until I have clear reproduction steps on a clean install.
Comment #18
John Eardley commentedI had this problem and solved it by going to my database and removing the records contained in File_managed. Note that I did not delete the file managed record - just emptied it.