Session Error in Cron run

Created on 21 December 2011, about 13 years ago
Updated 28 October 2024, about 2 months ago

I was was having an issue with the cron run expiring old session variables at linke 162.

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 query: DELETE FROM simple_cart WHERE sid IN (, , , , ,
...
all/modules/simple_cart/simple_cart.module on line 162.

I figured out the the implode that originally was there would not work with strings, it needs to be quoted.

You should never mix quoted and unquoted values in an IN list because the comparison rules for quoted values (such as strings) and unquoted values (such as numbers) differ. Mixing types may therefore lead to inconsistent results

From here

It was never expiring some of the rows. I added the \' at the beginning and end, and then added the single quotes to the implode.

 if (!empty($outdated_sids)) {
    $sql = 'DELETE FROM {%s} WHERE sid IN (\'%s\')';
    db_query($sql, SIMPLE_CART_TABLE_NAME, implode("','", $outdated_sids));
  }
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024