Skip to content

Commit

Permalink
(NFC) Small updates for current code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Aug 12, 2020
1 parent e0e8ce0 commit 0f8c68d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions CRM/Rpow/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/StateMachineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down

0 comments on commit 0f8c68d

Please sign in to comment.