From d81f323f32d0f57c0965734e31544f644f58c313 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 21 Nov 2013 15:54:02 -0800 Subject: [PATCH] Avoiding implicit transactions when applying * Some callers get the DB and flip DBO_TRX off, which does not help much if simply connecting to the DB starts a transaction. Change-Id: I2bc90a1cdeade13ccb546db1183ab08f25156da1 --- includes/db/DatabaseMysqlBase.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index e0ad0032e0..1f80aa7b2f 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -123,7 +123,12 @@ abstract class DatabaseMysqlBase extends DatabaseBase { // Set SQL mode, default is turning them all off, can be overridden or skipped with null if ( is_string( $wgSQLMode ) ) { $mode = $this->addQuotes( $wgSQLMode ); - $this->query( "SET sql_mode = $mode", __METHOD__ ); + // Use doQuery() to avoid opening implicit transactions (DBO_TRX) + $success = $this->doQuery( "SET sql_mode = $mode", __METHOD__ ); + if ( !$success ) { + wfLogDBError( "Error setting sql_mode to $mode on server {$this->mServer}" ); + return $this->reportConnectionError( "Error setting sql_mode to $mode" ); + } } $this->mOpened = true; -- 2.20.1