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
+ /**
+ * @var string Set by subclasses
+ */
+ public static $minimumVersion;
+
+ /**
+ * @var string Set by subclasses
+ */
+ protected static $notMiniumumVerisonMessage;
+
/**
* The database connection.
*
/**
* The database connection.
*
*/
protected $globalNames = [];
*/
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'.
*/
/**
* Return the internal name, e.g. 'mysql', or 'sqlite'.
*/
return $this->compiledDBs;
}
return $this->compiledDBs;
}
+ /**
+ * 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.
*
/**
* Get an instance of DatabaseInstaller for the specified DB type.
*
$type = strtolower( $type );
if ( !isset( $this->dbInstallers[$type] ) ) {
$type = strtolower( $type );
if ( !isset( $this->dbInstallers[$type] ) ) {
- $class = ucfirst( $type ) . 'Installer';
+ $class = self::getDBInstallerClass( $type );
$this->dbInstallers[$type] = new $class( $this );
}
$this->dbInstallers[$type] = new $class( $this );
}
// SQL Server 2005 RTM
// @todo Are SQL Express version numbers different?)
// 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
// These are schema-level privs
// Note: the web user will be created will full permissions if possible, this permission
$conn = $status->value;
// Check version
$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() );
public $supportedEngines = [ 'InnoDB', 'MyISAM' ];
public $supportedEngines = [ 'InnoDB', 'MyISAM' ];
- public $minimumVersion = '5.5.8';
+ public static $minimumVersion = '5.5.8';
+ protected static $notMiniumumVerisonMessage = 'config-mysql-old';
public $webUserPrivs = [
'DELETE',
public $webUserPrivs = [
'DELETE',
$conn = $status->value;
// Check version
$conn = $status->value;
// Check version
- $version = $conn->getServerVersion();
- if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
- return Status::newFatal( 'config-mysql-old', $this->minimumVersion, $version );
- }
-
- return $status;
+ return static::meetsMinimumRequirement( $conn->getServerVersion() );
+use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\DBConnectionError;
/**
use Wikimedia\Rdbms\DBConnectionError;
/**
'_InstallUser' => 'SYSTEM',
];
'_InstallUser' => 'SYSTEM',
];
- public $minimumVersion = '9.0.1'; // 9iR1
+ public static $minimumVersion = '9.0.1'; // 9iR1
+ protected static $notMiniumumVerisonMessage = 'config-oracle-old';
protected $connError = null;
protected $connError = null;
*/
$conn = $status->value;
// Check version
*/
$conn = $status->value;
// Check version
- $version = $conn->getServerVersion();
- if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
- return Status::newFatal( 'config-oracle-old', $this->minimumVersion, $version );
- }
+ $status->merge( static::meetsMinimumRequirement( $conn->getServerVersion() ) );
'_InstallUser' => 'postgres',
];
'_InstallUser' => 'postgres',
];
- public $minimumVersion = '8.3';
+ public static $minimumVersion = '8.3';
+ protected static $notMiniumumVerisonMessage = 'config-postgres-old';
public $maxRoleSearchDepth = 5;
protected $pgConns = [];
public $maxRoleSearchDepth = 5;
protected $pgConns = [];
// Check version
$version = $conn->getServerVersion();
// Check version
$version = $conn->getServerVersion();
- if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
- return Status::newFatal( 'config-postgres-old', $this->minimumVersion, $version );
+ $status = static::meetsMinimumRequirement( $conn->getServerVersion() );
+ if ( !$status->isOK() ) {
+ return $status;
}
$this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
}
$this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
*/
class SqliteInstaller extends DatabaseInstaller {
*/
class SqliteInstaller extends DatabaseInstaller {
- public $minimumVersion = '3.3.7';
+ public static $minimumVersion = '3.3.7';
+ protected static $notMiniumumVerisonMessage = 'config-outdated-sqlite';
/**
* @var DatabaseSqlite
/**
* @var DatabaseSqlite
* @return Status
*/
public function checkPrerequisites() {
* @return Status
*/
public function checkPrerequisites() {
- $result = Status::newGood();
// Bail out if SQLite is too old
$db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
// Bail out if SQLite is too old
$db = DatabaseSqlite::newStandaloneInstance( ':memory:' );
- if ( version_compare( $db->getServerVersion(), $this->minimumVersion, '<' ) ) {
- $result->fatal( 'config-outdated-sqlite', $db->getServerVersion(), $this->minimumVersion );
- }
+ $result = static::meetsMinimumRequirement( $db->getServerVersion() );
// Check for FTS3 full-text search module
if ( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
$result->warning( 'config-no-fts3' );
// Check for FTS3 full-text search module
if ( DatabaseSqlite::getFulltextSearchModule() != 'FTS3' ) {
$result->warning( 'config-no-fts3' );
# This will vomit up an error if there are permissions problems
$db = $this->getDB( DB_MASTER );
# This will vomit up an error if there are permissions problems
$db = $this->getDB( DB_MASTER );
+ # Check to see whether the database server meets the minimum requirements
+ /** @var DatabaseInstaller $dbInstallerClass */
+ $dbInstallerClass = Installer::getDBInstallerClass( $db->getType() );
+ $status = $dbInstallerClass::meetsMinimumRequirement( $db->getServerVersion() );
+ if ( !$status->isOK() ) {
+ // This might output some wikitext like <strong> but it should be comprehensible
+ $text = $status->getWikiText();
+ $this->error( $text, 1 );
+ }
+
$this->output( "Going to run database updates for " . wfWikiID() . "\n" );
if ( $db->getType() === 'sqlite' ) {
/** @var IMaintainableDatabase|DatabaseSqlite $db */
$this->output( "Going to run database updates for " . wfWikiID() . "\n" );
if ( $db->getType() === 'sqlite' ) {
/** @var IMaintainableDatabase|DatabaseSqlite $db */