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

Change subject: Inject schema vars into DatabaseMysql
......................................................................


Inject schema vars into DatabaseMysql

Also fix broken patchSql.php maintenance script

Change-Id: I45bccb0e2e10bd06651a551fa08ed0c66d11eb6a
---
M includes/installer/DatabaseUpdater.php
M includes/installer/MysqlUpdater.php
M includes/libs/rdbms/database/DatabaseMysqlBase.php
M maintenance/Maintenance.php
M maintenance/patchSql.php
M maintenance/sql.php
6 files changed, 42 insertions(+), 20 deletions(-)

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



diff --git a/includes/installer/DatabaseUpdater.php 
b/includes/installer/DatabaseUpdater.php
index 0e4b098..0d0da08 100644
--- a/includes/installer/DatabaseUpdater.php
+++ b/includes/installer/DatabaseUpdater.php
@@ -170,14 +170,14 @@
        }
 
        /**
-        * @param DatabaseBase $db
+        * @param Database $db
         * @param bool $shared
         * @param Maintenance $maintenance
         *
         * @throws MWException
         * @return DatabaseUpdater
         */
-       public static function newForDB( &$db, $shared = false, $maintenance = 
null ) {
+       public static function newForDB( Database $db, $shared = false, 
$maintenance = null ) {
                $type = $db->getType();
                if ( in_array( $type, Installer::getDBTypes() ) ) {
                        $class = ucfirst( $type ) . 'Updater';
@@ -403,6 +403,20 @@
        }
 
        /**
+        * Get appropriate schema variables in the current database connection.
+        *
+        * This should be called after any request data has been imported, but 
before
+        * any write operations to the database. The result should be passed to 
the DB
+        * setSchemaVars() method.
+        *
+        * @return array
+        * @since 1.28
+        */
+       public function getSchemaVars() {
+               return []; // DB-type specific
+       }
+
+       /**
         * Do all the updates
         *
         * @param array $what What updates to perform
@@ -410,6 +424,8 @@
        public function doUpdates( $what = [ 'core', 'extensions', 'stats' ] ) {
                global $wgVersion;
 
+               $this->db->setSchemaVars( $this->getSchemaVars() );
+
                $what = array_flip( $what );
                $this->skipSchema = isset( $what['noschema'] ) || 
$this->fileHandle !== null;
                if ( isset( $what['core'] ) ) {
diff --git a/includes/installer/MysqlUpdater.php 
b/includes/installer/MysqlUpdater.php
index 65af086..693b6ff 100644
--- a/includes/installer/MysqlUpdater.php
+++ b/includes/installer/MysqlUpdater.php
@@ -1122,4 +1122,18 @@
                        'Making rev_page_id index non-unique'
                );
        }
+
+       public function getSchemaVars() {
+               global $wgDBTableOptions;
+
+               $vars = [];
+               $vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', 
$wgDBTableOptions );
+               $vars['wgDBTableOptions'] = str_replace(
+                       'CHARSET=mysql4',
+                       'CHARSET=binary',
+                       $vars['wgDBTableOptions']
+               );
+
+               return $vars;
+       }
 }
diff --git a/includes/libs/rdbms/database/DatabaseMysqlBase.php 
b/includes/libs/rdbms/database/DatabaseMysqlBase.php
index 5134a4a..675bc87 100644
--- a/includes/libs/rdbms/database/DatabaseMysqlBase.php
+++ b/includes/libs/rdbms/database/DatabaseMysqlBase.php
@@ -1270,21 +1270,6 @@
        }
 
        /**
-        * @return array
-        */
-       protected function getDefaultSchemaVars() {
-               $vars = parent::getDefaultSchemaVars();
-               $vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', 
$GLOBALS['wgDBTableOptions'] );
-               $vars['wgDBTableOptions'] = str_replace(
-                       'CHARSET=mysql4',
-                       'CHARSET=binary',
-                       $vars['wgDBTableOptions']
-               );
-
-               return $vars;
-       }
-
-       /**
         * Get status information from SHOW STATUS in an associative array
         *
         * @param string $which
diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php
index 7e0fb45..e1a4dc6 100644
--- a/maintenance/Maintenance.php
+++ b/maintenance/Maintenance.php
@@ -1241,7 +1241,7 @@
         * @param integer $db DB index (DB_REPLICA/DB_MASTER)
         * @param array $groups; default: empty array
         * @param string|bool $wiki; default: current wiki
-        * @return IDatabase
+        * @return Database
         */
        protected function getDB( $db, $groups = [], $wiki = false ) {
                if ( is_null( $this->mDb ) ) {
diff --git a/maintenance/patchSql.php b/maintenance/patchSql.php
index 43fbd38..bc21140 100644
--- a/maintenance/patchSql.php
+++ b/maintenance/patchSql.php
@@ -45,11 +45,13 @@
 
        public function execute() {
                $dbw = $this->getDB( DB_MASTER );
+               $updater = DatabaseUpdater::newForDB( $dbw, true, $this );
+
                foreach ( $this->mArgs as $arg ) {
                        $files = [
                                $arg,
-                               $dbw->patchPath( $arg ),
-                               $dbw->patchPath( "patch-$arg.sql" ),
+                               $updater->patchPath( $dbw, $arg ),
+                               $updater->patchPath( $dbw, "patch-$arg.sql" ),
                        ];
                        foreach ( $files as $file ) {
                                if ( file_exists( $file ) ) {
diff --git a/maintenance/sql.php b/maintenance/sql.php
index a9fe45a..a9a982c 100644
--- a/maintenance/sql.php
+++ b/maintenance/sql.php
@@ -80,6 +80,11 @@
                        $this->error( "The server selected ({$db->getServer()}) 
is not a replica DB.", 1 );
                }
 
+               if ( $index === DB_MASTER ) {
+                       $updater = DatabaseUpdater::newForDB( $db, true, $this 
);
+                       $db->setSchemaVars( $updater->getSchemaVars() );
+               }
+
                if ( $this->hasArg( 0 ) ) {
                        $file = fopen( $this->getArg( 0 ), 'r' );
                        if ( !$file ) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I45bccb0e2e10bd06651a551fa08ed0c66d11eb6a
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@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

Reply via email to