Merge "Avoiding implicit transactions when applying"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 22 Nov 2013 00:47:13 +0000 (00:47 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 22 Nov 2013 00:47:13 +0000 (00:47 +0000)
includes/db/DatabaseMysqlBase.php

index e0ad003..1f80aa7 100644 (file)
@@ -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;