X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fdb%2FDatabaseMysqlBase.php;h=7b903d68266d3a2399e6eaaba27bbc5ed26c4358;hb=b29425e0b4bd90588fee46efafb58b5f41729033;hp=7cd55258b1bfae616e4e070e238ed53da4c4c2cc;hpb=d726bc7c3456d9742d4cb32640aa5847ad6b1782;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index 7cd55258b1..7b903d6826 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -71,8 +71,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { $this->mPassword = $password; $this->mDBname = $dbName; - wfProfileIn( "dbconnect-$server" ); - # The kernel's default SYN retransmission period is far too slow for us, # so we use a short timeout plus a manual retry. Retrying means that a small # but finite rate of SYN packet loss won't cause user-visible errors. @@ -81,14 +79,11 @@ abstract class DatabaseMysqlBase extends DatabaseBase { try { $this->mConn = $this->mysqlConnect( $realServer ); } catch ( Exception $ex ) { - wfProfileOut( "dbconnect-$server" ); $this->restoreErrorHandler(); throw $ex; } $error = $this->restoreErrorHandler(); - wfProfileOut( "dbconnect-$server" ); - # Always log connection errors if ( !$this->mConn ) { if ( !$error ) { @@ -105,7 +100,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { "Server: $server, User: $user, Password: " . substr( $password, 0, 3 ) . "..., error: " . $error . "\n" ); - $this->reportConnectionError( $error ); } @@ -123,7 +117,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { wfDebug( "Error selecting database $dbName on server {$this->mServer} " . "from client host " . wfHostname() . "\n" ); - $this->reportConnectionError( "Error selecting database $dbName" ); } } @@ -133,19 +126,25 @@ abstract class DatabaseMysqlBase extends DatabaseBase { $this->reportConnectionError( "Error setting character set" ); } + // Abstract over any insane MySQL defaults + $set = array( 'group_concat_max_len = 262144' ); // Set SQL mode, default is turning them all off, can be overridden or skipped with null if ( is_string( $wgSQLMode ) ) { - $mode = $this->addQuotes( $wgSQLMode ); + $set[] = 'sql_mode = ' . $this->addQuotes( $wgSQLMode ); + } + + if ( $set ) { // Use doQuery() to avoid opening implicit transactions (DBO_TRX) - $success = $this->doQuery( "SET sql_mode = $mode", __METHOD__ ); + $success = $this->doQuery( 'SET ' . implode( ', ', $set ), __METHOD__ ); if ( !$success ) { wfLogDBError( - "Error setting sql_mode to $mode on server {db_server}", + 'Error setting MySQL variables on server {db_server} (check $wgSQLMode)', $this->getLogContext( array( 'method' => __METHOD__, ) ) ); - $this->reportConnectionError( "Error setting sql_mode to $mode" ); + $this->reportConnectionError( + 'Error setting MySQL variables on server {db_server} (check $wgSQLMode)' ); } } @@ -701,7 +700,6 @@ abstract class DatabaseMysqlBase extends DatabaseBase { } } - return $status; }