[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_30]: Check minimum database server version when running update.php
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/385493 ) Change subject: Check minimum database server version when running update.php .. Check minimum database server version when running update.php If MediaWiki has increased the minimum database server version that is required, check it when running update.php to ensure it is still compatible. Previously this was only checked during the installer. Bug: T162044 Change-Id: I47092c9557f4706a4dcb3a23150647e68af4317f (cherry picked from commit 574ae4929e30700e29fef0e0d4f4824599205174) --- M includes/installer/DatabaseInstaller.php M includes/installer/Installer.php M includes/installer/MssqlInstaller.php M includes/installer/MysqlInstaller.php M includes/installer/OracleInstaller.php M includes/installer/PostgresInstaller.php M includes/installer/SqliteInstaller.php M maintenance/update.php 8 files changed, 68 insertions(+), 29 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 6c56b3d..925d991 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -42,6 +42,16 @@ public $parent; /** +* @var string Set by subclasses +*/ + public static $minimumVersion; + + /** +* @var string Set by subclasses +*/ + protected static $notMiniumumVerisonMessage; + + /** * The database connection. * * @var Database @@ -63,6 +73,23 @@ protected $globalNames = []; /** +* Whether the provided version meets the necessary requirements for this type +* +* @param string $serverVersion Output of Database::getServerVersion() +* @return Status +* @since 1.30 +*/ + public static function meetsMinimumRequirement( $serverVersion ) { + if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) { + return Status::newFatal( + static::$notMiniumumVerisonMessage, static::$minimumVersion, $serverVersion + ); + } + + return Status::newGood(); + } + + /** * Return the internal name, e.g. 'mysql', or 'sqlite'. */ abstract public function getName(); diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 52be321..012b477 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -547,6 +547,17 @@ } /** +* Get the DatabaseInstaller class name for this type +* +* @param string $type database type ($wgDBtype) +* @return string Class name +* @since 1.30 +*/ + public static function getDBInstallerClass( $type ) { + return ucfirst( $type ) . 'Installer'; + } + + /** * Get an instance of DatabaseInstaller for the specified DB type. * * @param mixed $type DB installer for which is needed, false to use default. @@ -561,7 +572,7 @@ $type = strtolower( $type ); if ( !isset( $this->dbInstallers[$type] ) ) { - $class = ucfirst( $type ) . 'Installer'; + $class = self::getDBInstallerClass( $type ); $this->dbInstallers[$type] = new $class( $this ); } diff --git a/includes/installer/MssqlInstaller.php b/includes/installer/MssqlInstaller.php index d01f954..e462220 100644 --- a/includes/installer/MssqlInstaller.php +++ b/includes/installer/MssqlInstaller.php @@ -51,7 +51,8 @@ // SQL Server 2005 RTM // @todo Are SQL Express version numbers different?) - public $minimumVersion = '9.00.1399'; + public static $minimumVersion = '9.00.1399'; + protected static $notMiniumumVerisonMessage = 'config-mssql-old'; // These are schema-level privs // Note: the web user will be created will full permissions if possible, this permission @@ -191,12 +192,7 @@ $conn = $status->value; // Check version - $version = $conn->getServerVersion(); - if ( version_compare( $version, $this->minimumVersion ) < 0 ) { - return Status::newFatal( 'config-mssql-old', $this->minimumVersion, $version ); - } - - return $status; + return static::meetsMinimumRequirement( $conn->getServerVersion() ); } /** diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index c5dd4dc..ab5701a 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -51,7 +51,8
[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_30]: Check minimum database server version when running update.php
Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/385493 ) Change subject: Check minimum database server version when running update.php .. Check minimum database server version when running update.php If MediaWiki has increased the minimum database server version that is required, check it when running update.php to ensure it is still compatible. Previously this was only checked during the installer. Bug: T162044 Change-Id: I47092c9557f4706a4dcb3a23150647e68af4317f (cherry picked from commit 574ae4929e30700e29fef0e0d4f4824599205174) --- M includes/installer/DatabaseInstaller.php M includes/installer/Installer.php M includes/installer/MssqlInstaller.php M includes/installer/MysqlInstaller.php M includes/installer/OracleInstaller.php M includes/installer/PostgresInstaller.php M includes/installer/SqliteInstaller.php M maintenance/update.php 8 files changed, 68 insertions(+), 29 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/93/385493/1 diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index 6c56b3d..925d991 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -42,6 +42,16 @@ public $parent; /** +* @var string Set by subclasses +*/ + public static $minimumVersion; + + /** +* @var string Set by subclasses +*/ + protected static $notMiniumumVerisonMessage; + + /** * The database connection. * * @var Database @@ -63,6 +73,23 @@ protected $globalNames = []; /** +* Whether the provided version meets the necessary requirements for this type +* +* @param string $serverVersion Output of Database::getServerVersion() +* @return Status +* @since 1.30 +*/ + public static function meetsMinimumRequirement( $serverVersion ) { + if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) { + return Status::newFatal( + static::$notMiniumumVerisonMessage, static::$minimumVersion, $serverVersion + ); + } + + return Status::newGood(); + } + + /** * Return the internal name, e.g. 'mysql', or 'sqlite'. */ abstract public function getName(); diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index 52be321..012b477 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -547,6 +547,17 @@ } /** +* Get the DatabaseInstaller class name for this type +* +* @param string $type database type ($wgDBtype) +* @return string Class name +* @since 1.30 +*/ + public static function getDBInstallerClass( $type ) { + return ucfirst( $type ) . 'Installer'; + } + + /** * Get an instance of DatabaseInstaller for the specified DB type. * * @param mixed $type DB installer for which is needed, false to use default. @@ -561,7 +572,7 @@ $type = strtolower( $type ); if ( !isset( $this->dbInstallers[$type] ) ) { - $class = ucfirst( $type ) . 'Installer'; + $class = self::getDBInstallerClass( $type ); $this->dbInstallers[$type] = new $class( $this ); } diff --git a/includes/installer/MssqlInstaller.php b/includes/installer/MssqlInstaller.php index d01f954..e462220 100644 --- a/includes/installer/MssqlInstaller.php +++ b/includes/installer/MssqlInstaller.php @@ -51,7 +51,8 @@ // SQL Server 2005 RTM // @todo Are SQL Express version numbers different?) - public $minimumVersion = '9.00.1399'; + public static $minimumVersion = '9.00.1399'; + protected static $notMiniumumVerisonMessage = 'config-mssql-old'; // These are schema-level privs // Note: the web user will be created will full permissions if possible, this permission @@ -191,12 +192,7 @@ $conn = $status->value; // Check version - $version = $conn->getServerVersion(); - if ( version_compare( $version, $this->minimumVersion ) < 0 ) { - return Status::newFatal( 'config-mssql-old', $this->minimumVersion, $version ); - } - - return $status; + return static::meetsMinimumRequirement( $conn->getServerVersion() ); } /** diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index c5dd4dc..ab5701a 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -51,7 +51,8