I clicked on "Empty cart" owhen the cart has (0) items and got this error message.
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1: SELECT tmgmt_message.mid AS entity_id, :entity_type AS entity_type, NULL AS revision_id, :bundle AS bundle FROM {tmgmt_message} tmgmt_message WHERE (tmgmt_message.tjiid IN ()) ; Array ( [:entity_type] => tmgmt_message [:bundle] => tmgmt_message ) in EntityFieldQuery->execute().
I think there should be a validation for number of items in the cart before trying to execute the empty cart query, this will prevent MySQL errors.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | tmgmt-pdoexception_when_trying_to_empty_cart-2629800-18.patch | 725 bytes | mqanneh |
| #11 | pdoexception_when_trying_to_empty_cart-2629800-11.patch | 788 bytes | mqanneh |
| #3 | pdoexception_when_trying_to_empty_cart-2629800-3.patch | 1.33 KB | mqanneh |
| sql-error.png | 50.48 KB | mqanneh | |
| empty_cart.png | 56.97 KB | mqanneh |
Comments
Comment #2
mqannehComment #3
mqannehComment #4
mqannehComment #5
mqannehComment #8
mqannehComment #9
berdirNice catch. I'd say this is major, not critical, since nothing is really broken after getting that error.
I don't think we need to introduce another message here. What would make more sense is to add an #access => count($job_items) or so to the delete button, so don't see it and it could only be an issue in case of race conditions with pressing the button multiple times or so.
Comment #10
mqannehGood suggestion, I assigned the issue to myself to work on it and post an updated patch soon.
Comment #11
mqanneh@Berdir check the updated patch for an alternative fix.
however, you can't rely on the count of items in the cart because it is always wrong.
you can check this issue that has a patch to fix number of items in the cart.
#2630104: Jobs number in cart is wrong
for this time you can test the last uploaded 2 patches ass these works fine - first patch (#2629800-3: PDOException: When trying to empty an empty cart) is better than the last one (#2629800-11: PDOException: When trying to empty an empty cart).
Comment #12
mpp commentedNice catch, patch in #11 seems to work fine.
In Drupal 8 this is solved by always keeping the "empty cart" link visible. When clicking it, you get the message: "All job items were removed from the cart.".
The tests on the 7.x dev branch seem to fail.
Comment #13
mqanneh@mpp if it worked for you can you update the ticket status to RTBC
Comment #14
mpp commentedComment #16
berdirCommitted, not sure about #12, seems like this might make sense in 8.x too.
Comment #17
mqanneh@Berdir
check this issue
https://www.drupal.org/node/2630104
It might be related and needs to committed as well
Comment #18
mqanneh@Berdir I rerolled the patch in #11 against the latest dev version of 8.x-1.x.