Bug fix for WordPress database error
-
Errors surfacing in our PHP logs:
WordPress database error 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 ‘WHERE 1 = 1 AND session_id=’k16jd8b356094f670bs1hog400” at line 1 for query SELECT * FROM WHERE 1 = 1 AND session_id=’k16jd8b356094f670bs1hog400’ made by Pantheon_Sessions\Session_Handler->write, Pantheon_Sessions\Session::get_by_sid
This plugin is running off a multi-node XtraDB cluster (Galera), mysql v5.7. Engine InnoDB.
Here’s the fix that resolved the issue.
In inc/class-session.php, line ~65, (above or below) add:
$table_name = $wpdb->pantheon_sessions;
Then change this at line ~68 from:
$session_row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->pantheon_sessions} WHERE {$column_name}=%s", $sid ) );
To:
$session_row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$table_name} WHERE {$column_name}=%s", $sid ) );
- The topic ‘Bug fix for WordPress database error’ is closed to new replies.