From 3535e21f37ca00cd14c04755b0c5adbc1d5c333c Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Fri, 25 Jun 2010 09:19:34 +0000 Subject: [PATCH] Adding $wgSQLMode * default is disabling all modes ('') * null disables the SET operation (we will use this at WMF deployment) * String override can be used as configuration parameter --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 8 ++++++++ includes/db/DatabaseMysql.php | 6 ++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a1d3b20f70..51495f4634 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -38,6 +38,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added $wgJQueryVersion, $wgJQueryMinified and $wgJQueryOnEveryPage (true by default) to configure loading of jQuery by MediaWiki. * XmlFunctions.php has been removed. Use the Xml or Html classes as appropriate. +* Added $wgSQLMode for setting database SQL modes - either performance (null) + or other reasons (such as enabling stricter checks) === New features in 1.17 === * (bug 10183) Users can now add personal styles and scripts to all skins via diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index f2c3b3366d..f21e4eb832 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1123,6 +1123,14 @@ $wgDBprefix = ''; /** MySQL table options to use during installation or update */ $wgDBTableOptions = 'ENGINE=InnoDB'; +/** + * SQL Mode - default is turning off all modes, including strict, if set. + * null can be used to skip the setting for performance reasons and assume + * DBA has done his best job. + * String override can be used for some additional fun :-) + */ +$wgSQLMode = ''; + /** Mediawiki schema */ $wgDBmwschema = 'mediawiki'; /** Tsearch2 schema */ diff --git a/includes/db/DatabaseMysql.php b/includes/db/DatabaseMysql.php index 68a7fee913..a23b7d2808 100644 --- a/includes/db/DatabaseMysql.php +++ b/includes/db/DatabaseMysql.php @@ -113,8 +113,10 @@ class DatabaseMysql extends DatabaseBase { if( $wgDBmysql5 ) { $this->query( 'SET NAMES utf8', __METHOD__ ); } - // Turn off strict mode - $this->query( "SET sql_mode = ''", __METHOD__ ); + // Set SQL mode, default is turning them all off, can be overridden or skipped with null + if (is_string($wgSQLMode)) { + $this->query( "SET sql_mode = '$wgSQLMode'", __METHOD__ ); + } } // Turn off strict mode if it is on -- 2.20.1