2010-07-20 10:03:27 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* DBMS-specific installation helper.
|
|
|
|
|
*
|
2012-05-06 05:50:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-08-21 18:20:09 +00:00
|
|
|
* @file
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-08-21 18:20:09 +00:00
|
|
|
*/
|
2019-06-29 07:58:02 +00:00
|
|
|
|
2017-02-07 04:49:57 +00:00
|
|
|
use Wikimedia\Rdbms\Database;
|
2019-02-11 11:49:38 +00:00
|
|
|
use Wikimedia\Rdbms\DBConnectionError;
|
2020-01-10 00:00:51 +00:00
|
|
|
use Wikimedia\Rdbms\DBExpectedError;
|
|
|
|
|
use Wikimedia\Rdbms\IDatabase;
|
|
|
|
|
use Wikimedia\Rdbms\LBFactorySingle;
|
2010-07-20 10:03:27 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-07-20 10:06:41 +00:00
|
|
|
* Base class for DBMS-specific installation helper classes.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2020-07-13 09:00:30 +00:00
|
|
|
* @stable to extend
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-07-29 18:36:39 +00:00
|
|
|
* @since 1.17
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 10:06:41 +00:00
|
|
|
abstract class DatabaseInstaller {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 11:17:36 +00:00
|
|
|
/**
|
|
|
|
|
* The Installer object.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2011-02-19 00:44:38 +00:00
|
|
|
* @var WebInstaller
|
2010-07-20 11:17:36 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public $parent;
|
2010-07-20 10:03:27 +00:00
|
|
|
|
2017-10-03 05:14:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var string Set by subclasses
|
|
|
|
|
*/
|
|
|
|
|
public static $minimumVersion;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string Set by subclasses
|
|
|
|
|
*/
|
2019-07-08 04:39:24 +00:00
|
|
|
protected static $notMinimumVersionMessage;
|
2017-10-03 05:14:33 +00:00
|
|
|
|
2010-07-20 11:17:36 +00:00
|
|
|
/**
|
|
|
|
|
* The database connection.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2016-09-28 22:53:02 +00:00
|
|
|
* @var Database
|
2010-07-20 11:17:36 +00:00
|
|
|
*/
|
2011-01-24 18:36:09 +00:00
|
|
|
public $db = null;
|
2010-07-20 10:03:27 +00:00
|
|
|
|
2010-07-20 11:17:36 +00:00
|
|
|
/**
|
|
|
|
|
* Internal variables for installation.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-20 11:17:36 +00:00
|
|
|
* @var array
|
|
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
protected $internalDefaults = [];
|
2010-07-20 10:03:27 +00:00
|
|
|
|
2010-07-20 11:17:36 +00:00
|
|
|
/**
|
|
|
|
|
* Array of MW configuration globals this class uses.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-20 11:17:36 +00:00
|
|
|
* @var array
|
|
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
protected $globalNames = [];
|
2010-07-20 10:03:27 +00:00
|
|
|
|
2017-10-03 05:14:33 +00:00
|
|
|
/**
|
|
|
|
|
* 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(
|
2019-07-08 04:39:24 +00:00
|
|
|
static::$notMinimumVersionMessage, static::$minimumVersion, $serverVersion
|
2017-10-03 05:14:33 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
/**
|
2010-07-20 11:00:51 +00:00
|
|
|
* Return the internal name, e.g. 'mysql', or 'sqlite'.
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function getName();
|
2010-07-20 10:03:27 +00:00
|
|
|
|
|
|
|
|
/**
|
2012-02-09 17:42:35 +00:00
|
|
|
* @return bool Returns true if the client library is compiled in.
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function isCompiled();
|
2010-07-20 10:03:27 +00:00
|
|
|
|
2012-01-04 10:41:39 +00:00
|
|
|
/**
|
|
|
|
|
* Checks for installation prerequisites other than those checked by isCompiled()
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2012-01-04 10:41:39 +00:00
|
|
|
* @since 1.19
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
public function checkPrerequisites() {
|
|
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
/**
|
|
|
|
|
* Get HTML for a web form that configures this database. Configuration
|
2010-12-06 20:04:28 +00:00
|
|
|
* at this time should be the minimum needed to connect and test
|
2010-07-20 10:03:27 +00:00
|
|
|
* whether install or upgrade is required.
|
|
|
|
|
*
|
2010-07-20 11:17:36 +00:00
|
|
|
* If this is called, $this->parent can be assumed to be a WebInstaller.
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function getConnectForm();
|
2010-07-20 10:03:27 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set variables based on the request array, assuming it was submitted
|
2010-12-06 20:04:28 +00:00
|
|
|
* via the form returned by getConnectForm(). Validate the connection
|
2010-07-20 10:03:27 +00:00
|
|
|
* settings by attempting to connect with them.
|
|
|
|
|
*
|
2010-07-20 11:17:36 +00:00
|
|
|
* If this is called, $this->parent can be assumed to be a WebInstaller.
|
2010-07-20 10:03:27 +00:00
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function submitConnectForm();
|
2010-07-20 10:03:27 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get HTML for a web form that retrieves settings used for installation.
|
|
|
|
|
* $this->parent can be assumed to be a WebInstaller.
|
2010-12-06 20:04:28 +00:00
|
|
|
* If the DB type has no settings beyond those already configured with
|
2010-07-20 10:03:27 +00:00
|
|
|
* getConnectForm(), this should return false.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2019-12-08 12:37:24 +00:00
|
|
|
* @return string|bool
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-09-01 18:10:02 +00:00
|
|
|
public function getSettingsForm() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-07-20 10:03:27 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set variables based on the request array, assuming it was submitted via
|
|
|
|
|
* the form return by getSettingsForm().
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-20 10:03:27 +00:00
|
|
|
* @return Status
|
|
|
|
|
*/
|
2010-09-01 18:10:02 +00:00
|
|
|
public function submitSettingsForm() {
|
|
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
2010-07-20 10:03:27 +00:00
|
|
|
|
|
|
|
|
/**
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
* Open a connection to the database using the administrative user/password
|
2011-02-12 04:06:22 +00:00
|
|
|
* currently defined in the session, without any caching. Returns a status
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
* object. On success, the status object will contain a Database object in
|
|
|
|
|
* its value member.
|
2010-11-10 16:06:16 +00:00
|
|
|
*
|
|
|
|
|
* @return Status
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function openConnection();
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
/**
|
|
|
|
|
* Create the database and return a Status object indicating success or
|
|
|
|
|
* failure.
|
|
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function setupDatabase();
|
2010-07-20 10:03:27 +00:00
|
|
|
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
/**
|
|
|
|
|
* Connect to the database using the administrative user/password currently
|
2011-02-12 04:06:22 +00:00
|
|
|
* defined in the session. Returns a status object. On success, the status
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
* object will contain a Database object in its value member.
|
2011-02-12 04:06:22 +00:00
|
|
|
*
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
* This will return a cached connection if one is available.
|
|
|
|
|
*
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2011-02-03 20:57:56 +00:00
|
|
|
* @return Status
|
2019-08-31 16:14:38 +00:00
|
|
|
* @suppress PhanUndeclaredMethod
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
*/
|
PostgreSQL install fixes:
* Made PG throw a DBQueryError when it gets a query error, instead of DBUnexpectedError. Apparently this mistake goes back to r14625, when exceptions were first introduced. Did it by removing reportQueryError(), the DatabaseBase version works fine.
* Fixed several places where there was an attempt to check for a query error by checking if the result of query() was false. This never worked. Used try/catch instead.
* Made the DBConnectionError messages go on one line so that they don't mess up the formatting in the installer.
* In DatabasePostgres::selectDB(), only disconnect and reconnect if the DB name is actually changing.
* Made DatabasePostgres::schemaExists() less weird and scary.
* Added DatabasePostgres::roleExists() for use by the installer.
* Removed the PostgreSQL-specific hack to make _InstallUser have a default other than "root". Made _InstallUser into a proper DBMS-specific internal variable instead, since every DBMS we support so far needs a different default.
* Removed the $dbName parameters from openConnection/getConnection, and got rid of $this->useAdmin. Implemented a more sophisticated caching scheme instead. Partial revert of r89389 and r81440.
* When connecting as the install user before DB creation, and when testing the web user's credentials, try a few different database names and use whichever one works.
* Instead of connecting as the web user to create tables, I used SET ROLE. It seems cleaner and more like what the other DBMSes do during installation. "SET ROLE wikiuser" requires the same privileges as "CREATE SCHEMA ... AUTHORIZATION wikiuser", so it's unlikely to break anything.
* In the area of web account creation, fixed various minor logic errors and introduced more informative error messages at the submit stage, pre-install. Show a helpful error message if the web user exists already and the install user can't do the relevant SET ROLE.
* Split schema creation out to a separate install step.
* When creating an account as a non-superuser, add the administrative account to the new account's group. This is necessary to avoid a fatal error during installation (bug 28845).
* Removed code which alters an existing web user to have appropriate search paths and permissions. This may break other apps and is not necessary. As in other DBMSes, If the web user exists, it is the responsibility of the sysadmin to ensure that it has appropriate permissions.
* Rewrote setupPLpgSQL() to use the query builder functions.
2011-06-10 11:32:57 +00:00
|
|
|
public function getConnection() {
|
|
|
|
|
if ( $this->db ) {
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
return Status::newGood( $this->db );
|
|
|
|
|
}
|
2011-06-03 03:41:11 +00:00
|
|
|
|
PostgreSQL install fixes:
* Made PG throw a DBQueryError when it gets a query error, instead of DBUnexpectedError. Apparently this mistake goes back to r14625, when exceptions were first introduced. Did it by removing reportQueryError(), the DatabaseBase version works fine.
* Fixed several places where there was an attempt to check for a query error by checking if the result of query() was false. This never worked. Used try/catch instead.
* Made the DBConnectionError messages go on one line so that they don't mess up the formatting in the installer.
* In DatabasePostgres::selectDB(), only disconnect and reconnect if the DB name is actually changing.
* Made DatabasePostgres::schemaExists() less weird and scary.
* Added DatabasePostgres::roleExists() for use by the installer.
* Removed the PostgreSQL-specific hack to make _InstallUser have a default other than "root". Made _InstallUser into a proper DBMS-specific internal variable instead, since every DBMS we support so far needs a different default.
* Removed the $dbName parameters from openConnection/getConnection, and got rid of $this->useAdmin. Implemented a more sophisticated caching scheme instead. Partial revert of r89389 and r81440.
* When connecting as the install user before DB creation, and when testing the web user's credentials, try a few different database names and use whichever one works.
* Instead of connecting as the web user to create tables, I used SET ROLE. It seems cleaner and more like what the other DBMSes do during installation. "SET ROLE wikiuser" requires the same privileges as "CREATE SCHEMA ... AUTHORIZATION wikiuser", so it's unlikely to break anything.
* In the area of web account creation, fixed various minor logic errors and introduced more informative error messages at the submit stage, pre-install. Show a helpful error message if the web user exists already and the install user can't do the relevant SET ROLE.
* Split schema creation out to a separate install step.
* When creating an account as a non-superuser, add the administrative account to the new account's group. This is necessary to avoid a fatal error during installation (bug 28845).
* Removed code which alters an existing web user to have appropriate search paths and permissions. This may break other apps and is not necessary. As in other DBMSes, If the web user exists, it is the responsibility of the sysadmin to ensure that it has appropriate permissions.
* Rewrote setupPLpgSQL() to use the query builder functions.
2011-06-10 11:32:57 +00:00
|
|
|
$status = $this->openConnection();
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
if ( $status->isOK() ) {
|
|
|
|
|
$this->db = $status->value;
|
|
|
|
|
// Enable autocommit
|
|
|
|
|
$this->db->clearFlag( DBO_TRX );
|
2012-02-26 17:19:11 +00:00
|
|
|
$this->db->commit( __METHOD__ );
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
/**
|
2014-05-25 11:23:09 +00:00
|
|
|
* Apply a SQL source file to the database as part of running an installation step.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2014-05-25 11:23:09 +00:00
|
|
|
* @param string $sourceFileMethod
|
|
|
|
|
* @param string $stepName
|
2021-05-28 20:57:13 +00:00
|
|
|
* @param bool|string $tableThatMustNotExist
|
2010-07-22 17:58:26 +00:00
|
|
|
* @return Status
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2014-05-25 11:23:09 +00:00
|
|
|
private function stepApplySourceFile(
|
|
|
|
|
$sourceFileMethod,
|
|
|
|
|
$stepName,
|
2021-05-28 20:57:13 +00:00
|
|
|
$tableThatMustNotExist = false
|
2014-05-25 11:23:09 +00:00
|
|
|
) {
|
2010-09-01 19:03:56 +00:00
|
|
|
$status = $this->getConnection();
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
|
|
|
|
|
|
2021-05-28 20:57:13 +00:00
|
|
|
if ( $tableThatMustNotExist && $this->db->tableExists( $tableThatMustNotExist, __METHOD__ ) ) {
|
2014-05-25 11:23:09 +00:00
|
|
|
$status->warning( "config-$stepName-tables-exist" );
|
2011-03-01 18:46:16 +00:00
|
|
|
$this->enableLB();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-09-01 19:03:56 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 19:22:27 +00:00
|
|
|
$this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
|
2011-01-14 20:43:14 +00:00
|
|
|
$this->db->begin( __METHOD__ );
|
|
|
|
|
|
2020-11-29 11:37:44 +00:00
|
|
|
// @phan-suppress-next-line SecurityCheck-PathTraversal False positive
|
2014-05-25 11:23:09 +00:00
|
|
|
$error = $this->db->sourceFile(
|
2016-09-15 09:25:16 +00:00
|
|
|
call_user_func( [ $this, $sourceFileMethod ], $this->db )
|
2014-05-25 11:23:09 +00:00
|
|
|
);
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $error !== true ) {
|
2011-01-02 19:04:23 +00:00
|
|
|
$this->db->reportQueryError( $error, 0, '', __METHOD__ );
|
2011-01-14 20:43:14 +00:00
|
|
|
$this->db->rollback( __METHOD__ );
|
2014-05-25 11:23:09 +00:00
|
|
|
$status->fatal( "config-$stepName-tables-failed", $error );
|
2011-01-14 20:43:14 +00:00
|
|
|
} else {
|
|
|
|
|
$this->db->commit( __METHOD__ );
|
2010-09-01 19:03:56 +00:00
|
|
|
}
|
2011-01-24 18:36:09 +00:00
|
|
|
// Resume normal operations
|
2016-03-19 00:08:06 +00:00
|
|
|
if ( $status->isOK() ) {
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
$this->enableLB();
|
2011-01-24 18:36:09 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-09-01 19:03:56 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
2010-07-20 10:03:27 +00:00
|
|
|
|
2014-05-25 11:23:09 +00:00
|
|
|
/**
|
2020-05-09 14:27:42 +00:00
|
|
|
* Create database tables from scratch from the automatically generated file
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2014-05-25 11:23:09 +00:00
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
public function createTables() {
|
2021-05-28 20:57:13 +00:00
|
|
|
return $this->stepApplySourceFile( 'getGeneratedSchemaPath', 'install', 'archive' );
|
2020-05-09 14:27:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create database tables from scratch.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2020-05-09 14:27:42 +00:00
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
public function createManualTables() {
|
2021-05-28 20:57:13 +00:00
|
|
|
return $this->stepApplySourceFile( 'getSchemaPath', 'install-manual' );
|
2014-05-25 11:23:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-05-28 21:36:27 +00:00
|
|
|
* Insert update keys into table to prevent running unneeded updates.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2014-05-25 11:23:09 +00:00
|
|
|
*
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
public function insertUpdateKeys() {
|
|
|
|
|
return $this->stepApplySourceFile( 'getUpdateKeysPath', 'updates', false );
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 09:25:16 +00:00
|
|
|
/**
|
|
|
|
|
* Return a path to the DBMS-specific SQL file if it exists,
|
|
|
|
|
* otherwise default SQL file
|
|
|
|
|
*
|
|
|
|
|
* @param IDatabase $db
|
|
|
|
|
* @param string $filename
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
private function getSqlFilePath( $db, $filename ) {
|
|
|
|
|
global $IP;
|
|
|
|
|
|
|
|
|
|
$dbmsSpecificFilePath = "$IP/maintenance/" . $db->getType() . "/$filename";
|
|
|
|
|
if ( file_exists( $dbmsSpecificFilePath ) ) {
|
|
|
|
|
return $dbmsSpecificFilePath;
|
|
|
|
|
} else {
|
|
|
|
|
return "$IP/maintenance/$filename";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a path to the DBMS-specific schema file,
|
|
|
|
|
* otherwise default to tables.sql
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2016-09-15 09:25:16 +00:00
|
|
|
*
|
|
|
|
|
* @param IDatabase $db
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getSchemaPath( $db ) {
|
|
|
|
|
return $this->getSqlFilePath( $db, 'tables.sql' );
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-09 14:27:42 +00:00
|
|
|
/**
|
|
|
|
|
* Return a path to the DBMS-specific automatically generated schema file.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2020-05-09 14:27:42 +00:00
|
|
|
*
|
|
|
|
|
* @param IDatabase $db
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getGeneratedSchemaPath( $db ) {
|
|
|
|
|
return $this->getSqlFilePath( $db, 'tables-generated.sql' );
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-15 09:25:16 +00:00
|
|
|
/**
|
|
|
|
|
* Return a path to the DBMS-specific update key file,
|
|
|
|
|
* otherwise default to update-keys.sql
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2016-09-15 09:25:16 +00:00
|
|
|
*
|
|
|
|
|
* @param IDatabase $db
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getUpdateKeysPath( $db ) {
|
|
|
|
|
return $this->getSqlFilePath( $db, 'update-keys.sql' );
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-31 20:00:59 +00:00
|
|
|
/**
|
|
|
|
|
* Create the tables for each extension the user enabled
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2011-01-31 20:00:59 +00:00
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
public function createExtensionTables() {
|
|
|
|
|
$status = $this->getConnection();
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
2011-03-30 17:32:20 +00:00
|
|
|
|
|
|
|
|
// Now run updates to create tables for old extensions
|
2020-11-03 06:00:34 +00:00
|
|
|
$updater = DatabaseUpdater::newForDB( $this->db );
|
|
|
|
|
$updater->setAutoExtensionHookContainer( $this->parent->getAutoExtensionHookContainer() );
|
|
|
|
|
$updater->doUpdates( [ 'extensions' ] );
|
2011-03-30 17:32:20 +00:00
|
|
|
|
2011-01-31 20:00:59 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 11:17:36 +00:00
|
|
|
/**
|
|
|
|
|
* Get the DBMS-specific options for LocalSettings.php generation.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return string
|
2010-07-20 11:17:36 +00:00
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function getLocalSettings();
|
2010-12-16 11:20:39 +00:00
|
|
|
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
/**
|
2011-02-12 04:06:22 +00:00
|
|
|
* Override this to provide DBMS-specific schema variables, to be
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
* substituted into tables.sql and other schema files.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2012-02-09 21:35:05 +00:00
|
|
|
* @return array
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
*/
|
|
|
|
|
public function getSchemaVars() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [];
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set appropriate schema variables in the current database connection.
|
|
|
|
|
*
|
|
|
|
|
* This should be called after any request data has been imported, but before
|
|
|
|
|
* any write operations to the database.
|
2020-07-10 12:58:33 +00:00
|
|
|
*
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
*/
|
|
|
|
|
public function setupSchemaVars() {
|
|
|
|
|
$status = $this->getConnection();
|
|
|
|
|
if ( $status->isOK() ) {
|
2019-08-31 16:14:38 +00:00
|
|
|
// @phan-suppress-next-line PhanUndeclaredMethod
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
$status->value->setSchemaVars( $this->getSchemaVars() );
|
2011-01-27 08:25:48 +00:00
|
|
|
} else {
|
2013-10-02 10:33:48 +00:00
|
|
|
$msg = __METHOD__ . ': unexpected error while establishing'
|
|
|
|
|
. ' a database connection with message: '
|
|
|
|
|
. $status->getMessage()->plain();
|
|
|
|
|
throw new MWException( $msg );
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up LBFactory so that wfGetDB() etc. works.
|
2011-02-12 04:06:22 +00:00
|
|
|
* We set up a special LBFactory instance which returns the current
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
* installer connection.
|
|
|
|
|
*/
|
|
|
|
|
public function enableLB() {
|
|
|
|
|
$status = $this->getConnection();
|
|
|
|
|
if ( !$status->isOK() ) {
|
2013-02-03 19:28:43 +00:00
|
|
|
throw new MWException( __METHOD__ . ': unexpected DB connection error' );
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
}
|
2016-05-01 19:29:11 +00:00
|
|
|
$connection = $status->value;
|
2020-09-17 19:12:33 +00:00
|
|
|
|
|
|
|
|
$this->parent->resetMediaWikiServices( null, [
|
2021-02-10 22:31:02 +00:00
|
|
|
'DBLoadBalancerFactory' => static function () use ( $connection ) {
|
2020-09-17 19:12:33 +00:00
|
|
|
return LBFactorySingle::newFromConnection( $connection );
|
|
|
|
|
}
|
|
|
|
|
] );
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
/**
|
|
|
|
|
* Perform database upgrades
|
2010-08-22 10:37:27 +00:00
|
|
|
*
|
2019-02-17 11:41:11 +00:00
|
|
|
* @suppress SecurityCheck-XSS Escaping provided by $this->outputHandler
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return bool
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-09-07 20:57:53 +00:00
|
|
|
public function doUpgrade() {
|
* Fixed a bug causing the installer to ignore the "engine" and "charset" settings when installing a MySQL database.
* Fixed a bug causing the engine and charset settings to not be properly preserved when adding new tables on upgrade.
* Fixed total breakage of SQLite upgrade, by reusing the administrative connection to the SQLite database instead of creating a new one when wfGetDB() is called. Added LBFactory_Single to support this.
* Introduced a "schema variable" concept to DatabaseBase to avoid the use of globals for communication between the installer and the Database. Removed a lot of old global variable names from Database::replaceVars(), most were only added on a whim and were never used.
* Introduced DatabaseInstaller::getSchemaVars(), to allow schema variables to be supplied by the DatabaseInstaller child classes.
* Removed messages config-mysql-egine-mismatch [sic] and config-mysql-charset-mismatch. In the old installer it was possible for users to request a certain character set for an upgrade, but in the new installer the question is never asked. So these warnings were shown whenever a non-default character set or engine was used in the old database.
* In MysqlInstaller::preUpgrade(), fixed the incorrect strings used to identify the MySQL character sets: mysql5 instead of utf8 and mysql5-binary instead of binary.
* On install, initialise the site_stats table, using code copied from the old installer. Unlike the old installer, use SiteStats to increment the user count when the initial user is added.
* Fixed several instances of inappropriate call-by-reference.
* Replaced call_user_func_array() with call_user_func() where possible, it is shorter and simpler.
* Moved the caching boilerplate for DatabaseInstaller::getConnection() to the base class, and have the derived classes override an uncached function openConnection() instead. Updates r80892.
* In MysqlInstaller::getLocalSettings(), escape PHP strings correctly with LocalSettingsGenerator::escapePhpString().
* Reduce timeout for checks in dirIsExecutable() to 3 seconds, so that it doesn't take 30s to run when apache is in single-threaded mode for debugging.
* MySQL and SQLite have been tested and they appear to work. PostgreSQL upgrade is totally broken, apparently it was like that before I started. The Oracle code is untested.
2011-01-25 07:37:48 +00:00
|
|
|
$this->setupSchemaVars();
|
|
|
|
|
$this->enableLB();
|
2010-09-07 20:57:53 +00:00
|
|
|
|
|
|
|
|
$ret = true;
|
2016-02-17 09:09:32 +00:00
|
|
|
ob_start( [ $this, 'outputHandler' ] );
|
2012-10-15 15:16:37 +00:00
|
|
|
$up = DatabaseUpdater::newForDB( $this->db );
|
2010-09-07 20:57:53 +00:00
|
|
|
try {
|
2010-10-01 20:39:07 +00:00
|
|
|
$up->doUpdates();
|
2018-11-16 22:54:59 +00:00
|
|
|
$up->purgeCache();
|
2016-09-23 03:42:38 +00:00
|
|
|
} catch ( MWException $e ) {
|
2012-08-10 08:59:55 +00:00
|
|
|
echo "\nAn error occurred:\n";
|
2010-09-07 20:57:53 +00:00
|
|
|
echo $e->getText();
|
|
|
|
|
$ret = false;
|
2016-09-23 03:42:38 +00:00
|
|
|
} catch ( Exception $e ) {
|
|
|
|
|
echo "\nAn error occurred:\n";
|
|
|
|
|
echo $e->getMessage();
|
|
|
|
|
$ret = false;
|
2010-09-07 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
ob_end_flush();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-09-07 20:57:53 +00:00
|
|
|
return $ret;
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 11:17:36 +00:00
|
|
|
/**
|
|
|
|
|
* Allow DB installers a chance to make last-minute changes before installation
|
|
|
|
|
* occurs. This happens before setupDatabase() or createTables() is called, but
|
|
|
|
|
* long after the constructor. Helpful for things like modifying setup steps :)
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2010-07-20 11:17:36 +00:00
|
|
|
*/
|
|
|
|
|
public function preInstall() {
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-22 10:37:27 +00:00
|
|
|
/**
|
|
|
|
|
* Allow DB installers a chance to make checks before upgrade.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2010-08-22 10:37:27 +00:00
|
|
|
*/
|
|
|
|
|
public function preUpgrade() {
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 11:17:36 +00:00
|
|
|
/**
|
|
|
|
|
* Get an array of MW configuration globals that will be configured by this class.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2012-02-09 21:35:05 +00:00
|
|
|
* @return array
|
2010-07-20 11:17:36 +00:00
|
|
|
*/
|
|
|
|
|
public function getGlobalNames() {
|
|
|
|
|
return $this->globalNames;
|
2010-12-06 20:04:28 +00:00
|
|
|
}
|
2010-07-20 10:03:27 +00:00
|
|
|
|
2010-12-06 20:04:28 +00:00
|
|
|
/**
|
2010-07-20 10:03:27 +00:00
|
|
|
* Construct and initialise parent.
|
|
|
|
|
* This is typically only called from Installer::getDBInstaller()
|
2020-07-13 08:53:06 +00:00
|
|
|
* @stable to call
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param WebInstaller $parent
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function __construct( $parent ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$this->parent = $parent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Convenience function.
|
|
|
|
|
* Check if a named extension is present.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $name
|
2011-10-18 17:26:09 +00:00
|
|
|
* @return bool
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
|
|
|
|
protected static function checkExtension( $name ) {
|
2013-10-09 16:46:57 +00:00
|
|
|
return extension_loaded( $name );
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get the internationalised name for this DBMS.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return string
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function getReadableName() {
|
2019-08-14 15:04:50 +00:00
|
|
|
// Messages: config-type-mysql, config-type-postgres, config-type-sqlite
|
2012-08-21 19:58:47 +00:00
|
|
|
return wfMessage( 'config-type-' . $this->getName() )->text();
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
/**
|
2015-01-11 18:30:43 +00:00
|
|
|
* Get a name=>value map of MW configuration globals for the default values.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2012-02-09 21:35:05 +00:00
|
|
|
* @return array
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function getGlobalDefaults() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$defaults = [];
|
2015-01-11 18:30:43 +00:00
|
|
|
foreach ( $this->getGlobalNames() as $var ) {
|
|
|
|
|
if ( isset( $GLOBALS[$var] ) ) {
|
|
|
|
|
$defaults[$var] = $GLOBALS[$var];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $defaults;
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get a name=>value map of internal variables used during installation.
|
2012-02-09 21:35:05 +00:00
|
|
|
* @return array
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
|
|
|
|
public function getInternalDefaults() {
|
|
|
|
|
return $this->internalDefaults;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get a variable, taking local defaults into account.
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $var
|
|
|
|
|
* @param mixed|null $default
|
2011-10-18 17:26:09 +00:00
|
|
|
* @return mixed
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function getVar( $var, $default = null ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$defaults = $this->getGlobalDefaults();
|
|
|
|
|
$internal = $this->getInternalDefaults();
|
|
|
|
|
if ( isset( $defaults[$var] ) ) {
|
|
|
|
|
$default = $defaults[$var];
|
|
|
|
|
} elseif ( isset( $internal[$var] ) ) {
|
|
|
|
|
$default = $internal[$var];
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
return $this->parent->getVar( $var, $default );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convenience alias for $this->parent->setVar()
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $name
|
|
|
|
|
* @param mixed $value
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function setVar( $name, $value ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$this->parent->setVar( $name, $value );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get a labelled text box to configure a local variable.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $var
|
|
|
|
|
* @param string $label
|
|
|
|
|
* @param array $attribs
|
2020-11-29 11:37:44 +00:00
|
|
|
* @param string $helpData HTML
|
|
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
public function getTextBox( $var, $label, $attribs = [], $helpData = "" ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$name = $this->getName() . '_' . $var;
|
|
|
|
|
$value = $this->getVar( $var );
|
2010-12-06 20:04:28 +00:00
|
|
|
if ( !isset( $attribs ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$attribs = [];
|
2010-12-06 20:04:28 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return $this->parent->getTextBox( [
|
2010-07-20 10:03:27 +00:00
|
|
|
'var' => $var,
|
|
|
|
|
'label' => $label,
|
|
|
|
|
'attribs' => $attribs,
|
|
|
|
|
'controlName' => $name,
|
2010-12-06 20:04:28 +00:00
|
|
|
'value' => $value,
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $helpData
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get a labelled password box to configure a local variable.
|
|
|
|
|
* Implements password hiding.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $var
|
|
|
|
|
* @param string $label
|
|
|
|
|
* @param array $attribs
|
2020-11-29 11:37:44 +00:00
|
|
|
* @param string $helpData HTML
|
|
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
public function getPasswordBox( $var, $label, $attribs = [], $helpData = "" ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$name = $this->getName() . '_' . $var;
|
|
|
|
|
$value = $this->getVar( $var );
|
2010-12-06 20:04:28 +00:00
|
|
|
if ( !isset( $attribs ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$attribs = [];
|
2010-12-06 20:04:28 +00:00
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return $this->parent->getPasswordBox( [
|
2010-07-20 10:03:27 +00:00
|
|
|
'var' => $var,
|
|
|
|
|
'label' => $label,
|
|
|
|
|
'attribs' => $attribs,
|
|
|
|
|
'controlName' => $name,
|
2010-12-06 20:04:28 +00:00
|
|
|
'value' => $value,
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $helpData
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get a labelled checkbox to configure a local boolean variable.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $var
|
|
|
|
|
* @param string $label
|
|
|
|
|
* @param array $attribs Optional.
|
|
|
|
|
* @param string $helpData Optional.
|
2011-05-02 16:58:29 +00:00
|
|
|
* @return string
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
public function getCheckBox( $var, $label, $attribs = [], $helpData = "" ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$name = $this->getName() . '_' . $var;
|
|
|
|
|
$value = $this->getVar( $var );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return $this->parent->getCheckBox( [
|
2010-07-20 10:03:27 +00:00
|
|
|
'var' => $var,
|
|
|
|
|
'label' => $label,
|
|
|
|
|
'attribs' => $attribs,
|
|
|
|
|
'controlName' => $name,
|
|
|
|
|
'value' => $value,
|
2010-12-19 04:31:15 +00:00
|
|
|
'help' => $helpData
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get a set of labelled radio buttons.
|
2010-07-20 10:03:27 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param array $params Parameters are:
|
2010-07-20 10:03:27 +00:00
|
|
|
* var: The variable to be configured (required)
|
|
|
|
|
* label: The message name for the label (required)
|
|
|
|
|
* itemLabelPrefix: The message name prefix for the item labels (required)
|
|
|
|
|
* values: List of allowed values (required)
|
|
|
|
|
* itemAttribs Array of attribute arrays, outer key is the value name (optional)
|
|
|
|
|
*
|
2012-02-09 21:35:05 +00:00
|
|
|
* @return string
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function getRadioSet( $params ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$params['controlName'] = $this->getName() . '_' . $params['var'];
|
|
|
|
|
$params['value'] = $this->getVar( $params['var'] );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
return $this->parent->getRadioSet( $params );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convenience function to set variables based on form data.
|
|
|
|
|
* Assumes that variables containing "password" in the name are (potentially
|
|
|
|
|
* fake) passwords.
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param array $varNames
|
2012-02-09 21:35:05 +00:00
|
|
|
* @return array
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function setVarsFromRequest( $varNames ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
return $this->parent->setVarsFromRequest( $varNames, $this->getName() . '_' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-12-06 20:04:28 +00:00
|
|
|
* Determine whether an existing installation of MediaWiki is present in
|
|
|
|
|
* the configured administrative connection. Returns true if there is
|
2010-07-20 10:03:27 +00:00
|
|
|
* such a wiki, false if the database doesn't exist.
|
|
|
|
|
*
|
2010-12-06 20:04:28 +00:00
|
|
|
* Traditionally, this is done by testing for the existence of either
|
2010-07-20 10:03:27 +00:00
|
|
|
* the revision table or the cur table.
|
|
|
|
|
*
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return bool
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function needsUpgrade() {
|
2010-07-20 10:03:27 +00:00
|
|
|
$status = $this->getConnection();
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-08-17 03:07:27 +00:00
|
|
|
|
2019-02-11 11:49:38 +00:00
|
|
|
try {
|
|
|
|
|
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
|
|
|
|
|
} catch ( DBConnectionError $e ) {
|
|
|
|
|
// Don't catch DBConnectionError
|
|
|
|
|
throw $e;
|
|
|
|
|
} catch ( DBExpectedError $e ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2013-10-23 12:16:03 +00:00
|
|
|
return $this->db->tableExists( 'cur', __METHOD__ ) ||
|
|
|
|
|
$this->db->tableExists( 'revision', __METHOD__ );
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Get a standard install-user fieldset.
|
2011-02-03 23:09:42 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return string
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function getInstallUserBox() {
|
2013-03-24 10:01:51 +00:00
|
|
|
return Html::openElement( 'fieldset' ) .
|
2016-02-17 09:09:32 +00:00
|
|
|
Html::element( 'legend', [], wfMessage( 'config-db-install-account' )->text() ) .
|
2020-12-30 18:38:48 +00:00
|
|
|
// @phan-suppress-next-line SecurityCheck-DoubleEscaped taint cannot track the helpbox from the rest
|
2013-10-23 12:16:03 +00:00
|
|
|
$this->getTextBox(
|
|
|
|
|
'_InstallUser',
|
|
|
|
|
'config-db-username',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'dir' => 'ltr' ],
|
2013-10-23 12:16:03 +00:00
|
|
|
$this->parent->getHelpBox( 'config-db-install-username' )
|
|
|
|
|
) .
|
2020-12-30 18:38:48 +00:00
|
|
|
// @phan-suppress-next-line SecurityCheck-DoubleEscaped taint cannot track the helpbox from the rest
|
2013-10-23 12:16:03 +00:00
|
|
|
$this->getPasswordBox(
|
|
|
|
|
'_InstallPassword',
|
|
|
|
|
'config-db-password',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'dir' => 'ltr' ],
|
2013-10-23 12:16:03 +00:00
|
|
|
$this->parent->getHelpBox( 'config-db-install-password' )
|
|
|
|
|
) .
|
2010-11-04 23:21:24 +00:00
|
|
|
Html::closeElement( 'fieldset' );
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-20 11:17:36 +00:00
|
|
|
* Submit a standard install user fieldset.
|
2012-02-09 21:35:05 +00:00
|
|
|
* @return Status
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function submitInstallUserBox() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->setVarsFromRequest( [ '_InstallUser', '_InstallPassword' ] );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a standard web-user fieldset
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string|bool $noCreateMsg Message to display instead of the creation checkbox.
|
|
|
|
|
* Set this to false to show a creation checkbox (default).
|
2011-02-03 23:09:42 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return string
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function getWebUserBox( $noCreateMsg = false ) {
|
2011-03-27 19:22:14 +00:00
|
|
|
$wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : '';
|
2010-11-04 23:23:34 +00:00
|
|
|
$s = Html::openElement( 'fieldset' ) .
|
2016-02-17 09:09:32 +00:00
|
|
|
Html::element( 'legend', [], wfMessage( 'config-db-web-account' )->text() ) .
|
2010-12-06 20:04:28 +00:00
|
|
|
$this->getCheckBox(
|
2010-07-20 10:03:27 +00:00
|
|
|
'_SameAccount', 'config-db-web-account-same',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' ]
|
2010-07-20 10:03:27 +00:00
|
|
|
) .
|
2016-02-17 09:09:32 +00:00
|
|
|
Html::openElement( 'div', [ 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ] ) .
|
2010-07-20 10:03:27 +00:00
|
|
|
$this->getTextBox( 'wgDBuser', 'config-db-username' ) .
|
|
|
|
|
$this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
|
|
|
|
|
$this->parent->getHelpBox( 'config-db-web-help' );
|
|
|
|
|
if ( $noCreateMsg ) {
|
2019-09-17 04:39:49 +00:00
|
|
|
$s .= Html::warningBox( wfMessage( $noCreateMsg )->plain(), 'config-warning-box' );
|
2010-07-20 10:03:27 +00:00
|
|
|
} else {
|
|
|
|
|
$s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' );
|
|
|
|
|
}
|
2010-11-04 23:21:24 +00:00
|
|
|
$s .= Html::closeElement( 'div' ) . Html::closeElement( 'fieldset' );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Submit the form from getWebUserBox().
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-20 10:03:27 +00:00
|
|
|
* @return Status
|
|
|
|
|
*/
|
2010-07-20 11:00:51 +00:00
|
|
|
public function submitWebUserBox() {
|
2010-07-20 11:17:36 +00:00
|
|
|
$this->setVarsFromRequest(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' ]
|
2010-07-20 11:17:36 +00:00
|
|
|
);
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
if ( $this->getVar( '_SameAccount' ) ) {
|
|
|
|
|
$this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
|
|
|
|
|
$this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
|
|
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $this->getVar( '_CreateDBAccount' ) && strval( $this->getVar( 'wgDBpassword' ) ) == '' ) {
|
2011-02-23 16:18:51 +00:00
|
|
|
return Status::newFatal( 'config-db-password-empty', $this->getVar( 'wgDBuser' ) );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-03-26 20:41:59 +00:00
|
|
|
* Common function for databases that don't understand the MySQLish syntax of interwiki.list.
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2011-02-03 23:09:42 +00:00
|
|
|
*
|
|
|
|
|
* @return Status
|
2010-07-20 10:03:27 +00:00
|
|
|
*/
|
|
|
|
|
public function populateInterwikiTable() {
|
|
|
|
|
$status = $this->getConnection();
|
|
|
|
|
if ( !$status->isOK() ) {
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
|
|
|
|
|
|
2017-10-12 18:34:15 +00:00
|
|
|
if ( $this->db->selectRow( 'interwiki', '1', [], __METHOD__ ) ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$status->warning( 'config-install-interwiki-exists' );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
global $IP;
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\suppressWarnings();
|
2010-07-20 10:03:27 +00:00
|
|
|
$rows = file( "$IP/maintenance/interwiki.list",
|
|
|
|
|
FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
|
2018-02-10 07:52:26 +00:00
|
|
|
Wikimedia\restoreWarnings();
|
2016-02-17 09:09:32 +00:00
|
|
|
$interwikis = [];
|
2010-07-20 10:03:27 +00:00
|
|
|
if ( !$rows ) {
|
2011-02-04 21:10:02 +00:00
|
|
|
return Status::newFatal( 'config-install-interwiki-list' );
|
2010-07-20 10:03:27 +00:00
|
|
|
}
|
2013-04-20 21:11:46 +00:00
|
|
|
foreach ( $rows as $row ) {
|
2010-07-20 10:03:27 +00:00
|
|
|
$row = preg_replace( '/^\s*([^#]*?)\s*(#.*)?$/', '\\1', $row ); // strip comments - whee
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $row == "" ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-09-17 19:42:35 +00:00
|
|
|
$row .= "|";
|
2010-07-20 10:03:27 +00:00
|
|
|
$interwikis[] = array_combine(
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'iw_prefix', 'iw_url', 'iw_local', 'iw_api', 'iw_wikiid' ],
|
2010-07-20 10:03:27 +00:00
|
|
|
explode( '|', $row )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$this->db->insert( 'interwiki', $interwikis, __METHOD__ );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-07-20 10:03:27 +00:00
|
|
|
return Status::newGood();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-01 18:16:05 +00:00
|
|
|
public function outputHandler( $string ) {
|
|
|
|
|
return htmlspecialchars( $string );
|
|
|
|
|
}
|
|
|
|
|
}
|