jenkins-bot has submitted this change and it was merged.

Change subject: Clean up $wgDBmwschema handling and only apply it to mssql
......................................................................


Clean up $wgDBmwschema handling and only apply it to mssql

Follow-up to 61762bf3f8f904bcc5a0f90985e7f787756032a7

Change-Id: Ib8dc247ba17d7cbf4cf0f46dbe82983a715f2c8d
---
M includes/db/loadbalancer/LBFactoryMW.php
M includes/libs/rdbms/database/Database.php
2 files changed, 14 insertions(+), 13 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/db/loadbalancer/LBFactoryMW.php 
b/includes/db/loadbalancer/LBFactoryMW.php
index 5db7736..69fd21d 100644
--- a/includes/db/loadbalancer/LBFactoryMW.php
+++ b/includes/db/loadbalancer/LBFactoryMW.php
@@ -28,7 +28,6 @@
  * @ingroup Database
  */
 abstract class LBFactoryMW extends LBFactory {
-       /** @noinspection PhpMissingParentConstructorInspection */
        /**
         * Construct a factory based on a configuration array (typically from 
$wgLBFactoryConf)
         * @param array $conf
@@ -44,7 +43,8 @@
         * @TODO: inject objects via dependency framework
         */
        public static function applyDefaultConfig( array $conf ) {
-               global $wgCommandLineMode, $wgSQLMode, $wgDBmysql5, $wgDBname, 
$wgDBprefix;
+               global $wgDBtype, $wgSQLMode, $wgDBmysql5, $wgDBname, 
$wgDBprefix, $wgDBmwschema;
+               global $wgCommandLineMode;
 
                $defaults = [
                        'localDomain' => new DatabaseDomain( $wgDBname, null, 
$wgDBprefix ),
@@ -73,9 +73,20 @@
                        $defaults['wanCache'] = $wCache;
                }
 
+               // Determine schema defaults. Currently Microsoft SQL Server 
uses $wgDBmwschema,
+               // and everything else doesn't use a schema (e.g. null)
+               // Although postgres and oracle support schemas, we don't use 
them (yet)
+               // to maintain backwards compatibility
+               $schema = ( $wgDBtype === 'mssql' ) ? $wgDBmwschema : null;
+
                if ( isset( $conf['serverTemplate'] ) ) { // LBFactoryMulti
+                       $conf['serverTemplate']['schema'] = $schema;
                        $conf['serverTemplate']['sqlMode'] = $wgSQLMode;
                        $conf['serverTemplate']['utf8Mode'] = $wgDBmysql5;
+               } elseif ( isset( $conf['servers'] ) ) { // LBFactorySimple
+                       foreach ( $conf['servers'] as $i => $server ) {
+                               $conf['servers'][$i]['schema'] = $schema;
+                       }
                }
 
                return $conf + $defaults;
diff --git a/includes/libs/rdbms/database/Database.php 
b/includes/libs/rdbms/database/Database.php
index 3672f4a..de0de6e 100644
--- a/includes/libs/rdbms/database/Database.php
+++ b/includes/libs/rdbms/database/Database.php
@@ -352,14 +352,6 @@
                                " no viable database extension found for type 
'$dbType'" );
                }
 
-               // Determine schema defaults. Currently Microsoft SQL Server 
uses $wgDBmwschema,
-               // and everything else doesn't use a schema (e.g. null)
-               // Although postgres and oracle support schemas, we don't use 
them (yet)
-               // to maintain backwards compatibility
-               $defaultSchemas = [
-                       'mssql' => 'get from global',
-               ];
-
                $class = 'Database' . ucfirst( $driver );
                if ( class_exists( $class ) && is_subclass_of( $class, 
'IDatabase' ) ) {
                        // Resolve some defaults for b/c
@@ -370,9 +362,7 @@
                        $p['flags'] = isset( $p['flags'] ) ? $p['flags'] : 0;
                        $p['variables'] = isset( $p['variables'] ) ? 
$p['variables'] : [];
                        $p['tablePrefix'] = isset( $p['tablePrefix'] ) ? 
$p['tablePrefix'] : '';
-                       if ( !isset( $p['schema'] ) ) {
-                               $p['schema'] = isset( $defaultSchemas[$dbType] 
) ? $defaultSchemas[$dbType] : '';
-                       }
+                       $p['schema'] = isset( $p['schema'] ) ? $p['schema'] : 
'';
                        $p['foreign'] = isset( $p['foreign'] ) ? $p['foreign'] 
: false;
 
                        $conn = new $class( $p );

-- 
To view, visit https://gerrit.wikimedia.org/r/310965
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8dc247ba17d7cbf4cf0f46dbe82983a715f2c8d
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
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

Reply via email to