diff --git a/CRM/Rpow/Classifier.php b/CRM/Rpow/Classifier.php index 4e52496..d2d311b 100644 --- a/CRM/Rpow/Classifier.php +++ b/CRM/Rpow/Classifier.php @@ -62,9 +62,15 @@ public function classify($rawSql) { // Micro-optimization: we'll execute most frequently in pure-read scenarios, so check those early on. if (mb_substr($sql, 0, 7) === 'select ') { - $isWrite = preg_match('; (for update|for share|into outfile|into dumpfile);', $sql) // keywords + + $isWrite = + preg_match('; (for update|for share|into outfile|into dumpfile);', $sql) + // ^^keywords + // FIXME: This is more correct, but civicrm-core may be a bit too eager with using them? - || preg_match(';[ ,\(](get_lock|is_free_lock|is_used_lock) *\(;S', $sql) // functions + || preg_match(';[ ,\(](get_lock|is_free_lock|is_used_lock) *\(;S', $sql) + // ^^functions + || ($trimmedSql === 'select "civirpow-force-write"') || ($trimmedSql === 'select \'civirpow-force-write\''); if ($isWrite) { diff --git a/tests/StateMachineTest.php b/tests/StateMachineTest.php index 224087c..d60aca1 100644 --- a/tests/StateMachineTest.php +++ b/tests/StateMachineTest.php @@ -22,7 +22,7 @@ public function testNormalLifecycle() { [ 'SET @contact_id = 123', 'CREATE TEMPORARY TABLE foobar AS SELECT id FROM whizbang', - 'UPDATE civicrm_contact SET do_not_phone = 1 WHERE id IN (SELECT id FROM foobar)' + 'UPDATE civicrm_contact SET do_not_phone = 1 WHERE id IN (SELECT id FROM foobar)', ], $s->getBuffer() );