HyperDB – is_write_query too strict
-
Came across an issue where only the first query (autoload options) was being sent to the read slave(s). Turns out a couple plugins had the syntax ‘SHOW TABLES LIKE…’ which HyperDB thought was a read query, since it didn’t match ‘SELECT’ as the first word. Made a quick fix for what I think are some common read statements to db.php:
function is_write_query( $q ) { $pattern = '/^\s*(SELECT|SHOW|DESCRIBE|EXPLAIN)\s+/i'; return (preg_match($pattern, $q)) ? false : true; }As you can see my regex-fu is weak, I spent a good 40 minutes trying to negatively match those words. Gave up, instead positively match them and then return true if there’s *not* a match.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘HyperDB – is_write_query too strict’ is closed to new replies.