Check minimum database server version when running update.php
[lhc/web/wiklou.git] / maintenance / update.php
index d96cecd..9f2fb92 100755 (executable)
@@ -27,6 +27,8 @@
 
 require_once __DIR__ . '/Maintenance.php';
 
+use Wikimedia\Rdbms\IMaintainableDatabase;
+
 /**
  * Maintenance script to run database schema updates.
  *
@@ -143,9 +145,19 @@ class UpdateMediaWiki extends Maintenance {
                # 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 Database|DatabaseSqlite $db */
+                       /** @var IMaintainableDatabase|DatabaseSqlite $db */
                        $this->output( "Using SQLite file: '{$db->getDbFilePath()}'\n" );
                }
                $this->output( "Depending on the size of your database this may take a while!\n" );