When updating an existing comment I get the following error:
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '52' for key 'PRIMARY': INSERT INTO {comment_notify} (cid, notify, notify_hash) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 52 [:db_insert_placeholder_1] => 0 [:db_insert_placeholder_2] => qECk4_EAzImRJJ3bvY9eogcdEyeac-iqJTVjcNRtbO8 ) in Drupal\Core\Database\Connection->handleQueryException() (line 668 of /var/www/html/core/lib/Drupal/Core/Database/Connection.php).
Comment | File | Size | Author |
---|---|---|---|
#8 | comment_notify_primary_key_violation-2823508-8.patch | 1.11 KB | nevergone |
| |||
#7 | comment_notify_primary_key_violation-2823508-7.patch | 1.36 KB | pcranston |
Comments
Comment #2
gnugetCan you please provide a list of steps to reproduce the problem?
Thanks.
Comment #3
gregglesBetter status for something where we need more info.
Comment #4
RobertoGuzman CreditAttribution: RobertoGuzman commentedi have the same error every time i'm updating an existing comment
Comment #5
greggles@RobertoGuzman, can you provide a set of steps to reproduce like:
1. Install Drupal 8
2. Configure X
3. Post a comment
4. Edit the comment
5. Observe the error message
Comment #6
RobertoGuzman CreditAttribution: RobertoGuzman commentedI post a comment, i saved it
I edit the comment, when i save it, i get the error
Comment #7
pcranston CreditAttribution: pcranston commentedI have the same issue as @Polly and @RobertoGuzman. My situation:
1. Drupal 8.3.7, 8.x-1.x-dev
2. Configure Comment Notify for a certain content type, nothing special here
3. Post a comment, with "Notify me when ..." set to unchecked
4. Edit that comment, leave "Notify me when ..." as unchecked, click save
5. Observe error message about comment notify integrity constraint violation
The problem is line 140:
If you unchecked the comment notify when submitting the comment, then comment_notify_get_notification_type() returns the value of notify = 0, and this if condition is not matched. In other words, it's checking whether it's set to on or off, not whether the database record exists, which is what it should be doing here. The code then proceeds to the comment_notify_add_notification() insert at line 153.
The attached patch as an additional function, comment_notify_get_notification_id() which checks whether the database record exists at all, regardless of the value of the 'notify' column, and will return the correct value to the submit function.
Comment #8
nevergone CreditAttribution: nevergone commentedRe-rolled patch.
Comment #9
gnugetCan we stop using db_select? and start using the new API?
Thanks!
Comment #10
nkoporecThis issue is related to Integrity constraint violation on anonymous's user comment update, which has a working patch.
Comment #11
gregglesI committed that and created a new release at https://www.drupal.org/project/comment_notify/releases/8.x-1.0-beta2
For those following this issue I hope you will test it out and confirm if it works for you and confirm if this issue is a duplicate of that.