jenkins-bot has submitted this change and it was merged. Change subject: Allow setting MySQL session variables via config ......................................................................
Allow setting MySQL session variables via config Change-Id: I39c7e0f5ffe53a3fb15da489f4dddc36af99a4b3 --- M includes/db/Database.php M includes/db/DatabaseMysqlBase.php 2 files changed, 14 insertions(+), 0 deletions(-) Approvals: Chad: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/db/Database.php b/includes/db/Database.php index 8c1ebf9..605dc7c 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -69,6 +69,8 @@ protected $mLBInfo = array(); protected $mDefaultBigSelects = null; protected $mSchemaVars = false; + /** @var array */ + protected $mSessionVars = array(); protected $preparedArgs; @@ -813,6 +815,8 @@ } } + $this->mSessionVars = $params['variables']; + /** Get the default table prefix*/ if ( $tablePrefix == 'get from global' ) { $this->mTablePrefix = $wgDBprefix; @@ -926,6 +930,7 @@ $p['password'] = isset( $p['password'] ) ? $p['password'] : false; $p['dbname'] = isset( $p['dbname'] ) ? $p['dbname'] : false; $p['flags'] = isset( $p['flags'] ) ? $p['flags'] : 0; + $p['variables'] = isset( $p['variables'] ) ? $p['variables'] : array(); $p['tablePrefix'] = isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : 'get from global'; $p['schema'] = isset( $p['schema'] ) ? $p['schema'] : $defaultSchemas[$dbType]; $p['foreign'] = isset( $p['foreign'] ) ? $p['foreign'] : false; diff --git a/includes/db/DatabaseMysqlBase.php b/includes/db/DatabaseMysqlBase.php index aac95a8..89d3456 100644 --- a/includes/db/DatabaseMysqlBase.php +++ b/includes/db/DatabaseMysqlBase.php @@ -132,6 +132,15 @@ if ( is_string( $wgSQLMode ) ) { $set[] = 'sql_mode = ' . $this->addQuotes( $wgSQLMode ); } + // Set any custom settings defined by site config + // (e.g. https://dev.mysql.com/doc/refman/4.1/en/innodb-parameters.html) + foreach ( $this->mSessionVars as $var => $val ) { + // Escape strings but not numbers to avoid MySQL complaining + if ( !is_int( $val ) && !is_float( $val ) ) { + $val = $this->addQuotes( $val ); + } + $set[] = $this->addIdentifierQuotes( $var ) . ' = ' . $val; + } if ( $set ) { // Use doQuery() to avoid opening implicit transactions (DBO_TRX) -- To view, visit https://gerrit.wikimedia.org/r/206418 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I39c7e0f5ffe53a3fb15da489f4dddc36af99a4b3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits