From b12b7e4ddb74304c284a3565272d58f2de95d470 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 29 Jun 2019 00:58:02 -0700 Subject: [PATCH] installer: Stop offering MyISAM option for new installs and fix bogus method calls The methods were renamed in 2010 (r68908, c4100fb83b5b12bd). Change-Id: I076ec8d9c11f5bd33cb0ad19e5be8e239401b9c6 --- includes/installer/DatabaseInstaller.php | 6 ++-- includes/installer/MssqlInstaller.php | 5 +-- includes/installer/MysqlInstaller.php | 44 ++---------------------- includes/installer/i18n/en.json | 3 -- includes/installer/i18n/qqq.json | 3 -- 5 files changed, 10 insertions(+), 51 deletions(-) diff --git a/includes/installer/DatabaseInstaller.php b/includes/installer/DatabaseInstaller.php index f9479796d6..ba5da6de50 100644 --- a/includes/installer/DatabaseInstaller.php +++ b/includes/installer/DatabaseInstaller.php @@ -20,6 +20,8 @@ * @file * @ingroup Deployment */ + +use MediaWiki\MediaWikiServices; use Wikimedia\Rdbms\LBFactorySingle; use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\IDatabase; @@ -359,8 +361,8 @@ abstract class DatabaseInstaller { throw new MWException( __METHOD__ . ': unexpected DB connection error' ); } - \MediaWiki\MediaWikiServices::resetGlobalInstance(); - $services = \MediaWiki\MediaWikiServices::getInstance(); + MediaWikiServices::resetGlobalInstance(); + $services = MediaWikiServices::getInstance(); $connection = $status->value; $services->redefineService( 'DBLoadBalancerFactory', function () use ( $connection ) { diff --git a/includes/installer/MssqlInstaller.php b/includes/installer/MssqlInstaller.php index ffa17edd90..8b5ff116a8 100644 --- a/includes/installer/MssqlInstaller.php +++ b/includes/installer/MssqlInstaller.php @@ -212,6 +212,7 @@ class MssqlInstaller extends DatabaseInstaller { } try { + /** @var DatabaseMssql $db */ $db = Database::factory( 'mssql', [ 'host' => $this->getVar( 'wgDBserver' ), 'port' => $this->getVar( 'wgDBport' ), @@ -236,7 +237,7 @@ class MssqlInstaller extends DatabaseInstaller { $status = $this->getConnection(); if ( !$status->isOK() ) { - $this->parent->showStatusError( $status ); + $this->parent->showStatusMessage( $status ); return; } @@ -594,7 +595,7 @@ class MssqlInstaller extends DatabaseInstaller { // Try to grant to all the users we know exist or we were able to create $this->db->selectDB( $dbName ); - foreach ( $grantableNames as $name ) { + if ( $grantableNames ) { try { // First try to grant full permissions $fullPrivArr = [ diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 3013db78bc..69d03bde6c 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -48,7 +48,7 @@ class MysqlInstaller extends DatabaseInstaller { '_InstallUser' => 'root', ]; - public $supportedEngines = [ 'InnoDB', 'MyISAM' ]; + public $supportedEngines = [ 'InnoDB' ]; public static $minimumVersion = '5.5.8'; protected static $notMinimumVersionMessage = 'config-mysql-old'; @@ -142,6 +142,7 @@ class MysqlInstaller extends DatabaseInstaller { public function openConnection() { $status = Status::newGood(); try { + /** @var DatabaseMysqlBase $db */ $db = Database::factory( 'mysql', [ 'host' => $this->getVar( 'wgDBserver' ), 'user' => $this->getVar( '_InstallUser' ), @@ -162,7 +163,7 @@ class MysqlInstaller extends DatabaseInstaller { $status = $this->getConnection(); if ( !$status->isOK() ) { - $this->parent->showStatusError( $status ); + $this->parent->showStatusMessage( $status ); return; } @@ -364,45 +365,6 @@ class MysqlInstaller extends DatabaseInstaller { $this->setVar( '_MysqlEngine', reset( $engines ) ); } - $s .= Xml::openElement( 'div', [ - 'id' => 'dbMyisamWarning' - ] ); - $myisamWarning = 'config-mysql-myisam-dep'; - if ( count( $engines ) === 1 ) { - $myisamWarning = 'config-mysql-only-myisam-dep'; - } - $s .= $this->parent->getWarningBox( wfMessage( $myisamWarning )->text() ); - $s .= Xml::closeElement( 'div' ); - - if ( $this->getVar( '_MysqlEngine' ) != 'MyISAM' ) { - $s .= Xml::openElement( 'script' ); - $s .= '$(\'#dbMyisamWarning\').hide();'; - $s .= Xml::closeElement( 'script' ); - } - - if ( count( $engines ) >= 2 ) { - // getRadioSet() builds a set of labeled radio buttons. - // For grep: The following messages are used as the item labels: - // config-mysql-innodb, config-mysql-myisam - $s .= $this->getRadioSet( [ - 'var' => '_MysqlEngine', - 'label' => 'config-mysql-engine', - 'itemLabelPrefix' => 'config-mysql-', - 'values' => $engines, - 'itemAttribs' => [ - 'MyISAM' => [ - 'class' => 'showHideRadio', - 'rel' => 'dbMyisamWarning' - ], - 'InnoDB' => [ - 'class' => 'hideShowRadio', - 'rel' => 'dbMyisamWarning' - ] - ] - ] ); - $s .= $this->parent->getHelpBox( 'config-mysql-engine-help' ); - } - // If the current default charset is not supported, use a charset that is $charsets = $this->getCharsets(); if ( !in_array( $this->getVar( '_MysqlCharset' ), $charsets ) ) { diff --git a/includes/installer/i18n/en.json b/includes/installer/i18n/en.json index 52d8d3db80..a9da56dc43 100644 --- a/includes/installer/i18n/en.json +++ b/includes/installer/i18n/en.json @@ -162,9 +162,6 @@ "config-db-web-no-create-privs": "The account you specified for installation does not have enough privileges to create an account.\nThe account you specify here must already exist.", "config-mysql-engine": "Storage engine:", "config-mysql-innodb": "InnoDB (recommended)", - "config-mysql-myisam": "MyISAM", - "config-mysql-myisam-dep": "Warning: You have selected MyISAM as storage engine for MySQL, which is not recommended for use with MediaWiki, because:\n* it barely supports concurrency due to table locking\n* it is more prone to corruption than other engines\n* the MediaWiki codebase does not always handle MyISAM as it should\n\nIf your MySQL installation supports InnoDB, it is highly recommended that you choose that instead.\nIf your MySQL installation does not support InnoDB, maybe it's time for an upgrade.", - "config-mysql-only-myisam-dep": "Warning: MyISAM is the only available storage engine for MySQL on this machine, and this is not recommended for use with MediaWiki, because:\n* it barely supports concurrency due to table locking\n* it is more prone to corruption than other engines\n* the MediaWiki codebase does not always handle MyISAM as it should\n\nYour MySQL installation does not support InnoDB, maybe it's time for an upgrade.", "config-mysql-engine-help": "InnoDB is almost always the best option, since it has good concurrency support.\n\nMyISAM may be faster in single-user or read-only installations.\nMyISAM databases tend to get corrupted more often than InnoDB databases.", "config-mssql-auth": "Authentication type:", "config-mssql-install-auth": "Select the authentication type that will be used to connect to the database during the installation process.\nIf you select \"{{int:config-mssql-windowsauth}}\", the credentials of whatever user the webserver is running as will be used.", diff --git a/includes/installer/i18n/qqq.json b/includes/installer/i18n/qqq.json index eddee83e16..039cd263af 100644 --- a/includes/installer/i18n/qqq.json +++ b/includes/installer/i18n/qqq.json @@ -185,9 +185,6 @@ "config-db-web-no-create-privs": "Error message in the MediaWiki installer.", "config-mysql-engine": "Field label for MySQL storage engine in the MediaWiki installer.", "config-mysql-innodb": "Option for the MySQL storage engine in the MediaWiki installer.", - "config-mysql-myisam": "Option for the MySQL storage engine in the MediaWiki installer.", - "config-mysql-myisam-dep": "Warning message in the MediaWiki installer when MyISAM is chosen as MySQL storage engine.", - "config-mysql-only-myisam-dep": "Used as warning message when mysql does not support the minimum suggested feature set.", "config-mysql-engine-help": "Help text in MediaWiki installer with advice for picking a MySQL storage engine.", "config-mssql-auth": "Radio button group label.\n\nFollowed by the following radio button labels:\n* {{msg-mw|Config-mssql-sqlauth}}\n* {{msg-mw|Config-mssql-windowsauth}}", "config-mssql-install-auth": "Used as the help text for the \"Authentication type\" radio button when typing in database settings for installation.\n\nRefers to {{msg-mw|Config-mssql-windowsauth}}.\n\nSee also:\n* {{msg-mw|Config-mssql-web-auth}}", -- 2.20.1