*/
public $parent;
+ /**
+ * @var string Set by subclasses
+ */
+ public static $minimumVersion;
+
+ /**
+ * @var string Set by subclasses
+ */
+ protected static $notMiniumumVerisonMessage;
+
/**
* The database connection.
*
*/
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'.
*/
}
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
- if ( $this->db->selectRow( 'interwiki', '*', [], __METHOD__ ) ) {
+ if ( $this->db->selectRow( 'interwiki', '1', [], __METHOD__ ) ) {
$status->warning( 'config-install-interwiki-exists' );
return $status;
'_InstallUser' => 'postgres',
];
- public $minimumVersion = '8.3';
+ public static $minimumVersion = '8.3';
+ protected static $notMiniumumVerisonMessage = 'config-postgres-old';
public $maxRoleSearchDepth = 5;
protected $pgConns = [];
// 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' ) );
public function setupPLpgSQL() {
// Connect as the install user, since it owns the database and so is
- // the user that needs to run "CREATE LANGAUGE"
+ // the user that needs to run "CREATE LANGUAGE"
$status = $this->getPgConnection( 'create-schema' );
if ( !$status->isOK() ) {
return $status;
$this->compatChecks();
} else {
$this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" );
- wfCountDown( 5 );
+ $this->countDown( 5 );
}
// Check external dependencies are up to date
# 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 */
if ( !$this->hasOption( 'quick' ) ) {
$this->output( "Abort with control-c in the next five seconds "
. "(skip this countdown with --quick) ... " );
- wfCountDown( 5 );
+ $this->countDown( 5 );
}
$time1 = microtime( true );