From: Aaron Schulz Date: Wed, 14 Jan 2015 00:57:52 +0000 (-0800) Subject: Always set group_concat_max_len to avoid awful truncation gotcha X-Git-Tag: 1.31.0-rc.0~12634^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=c73cd2ef7c8bc36e8d0e1e6970347df564782db3;p=lhc%2Fweb%2Fwiklou.git Always set group_concat_max_len to avoid awful truncation gotcha Change-Id: I1000412a0c58a9d76ea25f6ecc37a3a464aa430a --- diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index f02aa93a41..7b903d6826 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -126,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)' ); } }