From: Roan Kattouw Date: Wed, 12 Jun 2019 23:29:50 +0000 (-0700) Subject: Database: Recognize USE queries as non-write queries X-Git-Tag: 1.34.0-rc.0~1437^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=201c8d34975165405d7ba014f05656e586d882f0;p=lhc%2Fweb%2Fwiklou.git Database: Recognize USE queries as non-write queries This should unbreak Ie7341a0e6c41, which switched DatabaseMysql::doSelectDomain() from using doQuery() to using executeQuery() for its USE query, which means it no longer bypasses the isWriteQuery() check. This caused every USE query on a replica DB to fail, because it was considered a write query. Bug: T225682 Bug: T212284 Change-Id: Iecb8b9f6e64d08df8c64b3133078b5324e654ed1 Follows-Up: Ie7341a0e6c4149fc375cc357877486efe9e56eb9 --- diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index ab718ec267..a2caa96a96 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -1120,11 +1120,11 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware // for all queries within a request. Use cases: // - Treating these as writes would trigger ChronologyProtector (see method doc). // - We use this method to reject writes to replicas, but we need to allow - // use of transactions on replicas for read snapshots. This fine given + // use of transactions on replicas for read snapshots. This is fine given // that transactions by themselves don't make changes, only actual writes // within the transaction matter, which we still detect. return !preg_match( - '/^(?:SELECT|BEGIN|ROLLBACK|COMMIT|SAVEPOINT|RELEASE|SET|SHOW|EXPLAIN|\(SELECT)\b/i', + '/^(?:SELECT|BEGIN|ROLLBACK|COMMIT|SAVEPOINT|RELEASE|SET|SHOW|EXPLAIN|USE|\(SELECT)\b/i', $sql ); }