From c73cd2ef7c8bc36e8d0e1e6970347df564782db3 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 13 Jan 2015 16:57:52 -0800 Subject: [PATCH] Always set group_concat_max_len to avoid awful truncation gotcha Change-Id: I1000412a0c58a9d76ea25f6ecc37a3a464aa430a --- includes/db/DatabaseMysqlBase.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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)' ); } } -- 2.20.1