Go to the documentation of this file.
85 if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) {
87 static::$notMinimumVersionMessage, static::$minimumVersion, $serverVersion
97 abstract public function getName();
191 $this->db->clearFlag(
DBO_TRX );
192 $this->db->commit( __METHOD__ );
209 $archiveTableMustNotExist =
false
215 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
217 if ( $archiveTableMustNotExist && $this->db->tableExists(
'archive', __METHOD__ ) ) {
218 $status->warning(
"config-$stepName-tables-exist" );
225 $this->db->begin( __METHOD__ );
227 $error = $this->db->sourceFile(
228 call_user_func( [ $this, $sourceFileMethod ], $this->db )
230 if ( $error !==
true ) {
231 $this->db->reportQueryError( $error, 0,
'', __METHOD__ );
232 $this->db->rollback( __METHOD__ );
233 $status->fatal(
"config-$stepName-tables-failed", $error );
235 $this->db->commit( __METHOD__ );
274 $dbmsSpecificFilePath =
"$IP/maintenance/" .
$db->
getType() .
"/$filename";
275 if ( file_exists( $dbmsSpecificFilePath ) ) {
276 return $dbmsSpecificFilePath;
278 return "$IP/maintenance/$filename";
348 $msg = __METHOD__ .
': unexpected error while establishing'
349 .
' a database connection with message: '
350 .
$status->getMessage()->plain();
363 throw new MWException( __METHOD__ .
': unexpected DB connection error' );
366 MediaWikiServices::resetGlobalInstance();
367 $services = MediaWikiServices::getInstance();
370 $services->redefineService(
'DBLoadBalancerFactory',
function () use ( $connection ) {
371 return LBFactorySingle::newFromConnection( $connection );
386 ob_start( [ $this,
'outputHandler' ] );
392 echo
"\nAn error occurred:\n";
395 }
catch ( Exception $e ) {
396 echo
"\nAn error occurred:\n";
397 echo $e->getMessage();
444 return extension_loaded( $name );
484 public function getVar( $var, $default =
null ) {
487 if ( isset( $defaults[$var] ) ) {
488 $default = $defaults[$var];
489 } elseif ( isset( $internal[$var] ) ) {
490 $default = $internal[$var];
493 return $this->parent->getVar( $var, $default );
501 public function setVar( $name, $value ) {
502 $this->parent->setVar( $name, $value );
514 public function getTextBox( $var, $label, $attribs = [], $helpData =
"" ) {
515 $name = $this->
getName() .
'_' . $var;
516 $value = $this->
getVar( $var );
517 if ( !isset( $attribs ) ) {
521 return $this->parent->getTextBox( [
524 'attribs' => $attribs,
525 'controlName' => $name,
542 $name = $this->
getName() .
'_' . $var;
543 $value = $this->
getVar( $var );
544 if ( !isset( $attribs ) ) {
548 return $this->parent->getPasswordBox( [
551 'attribs' => $attribs,
552 'controlName' => $name,
567 public function getCheckBox( $var, $label, $attribs = [], $helpData =
"" ) {
568 $name = $this->
getName() .
'_' . $var;
569 $value = $this->
getVar( $var );
571 return $this->parent->getCheckBox( [
574 'attribs' => $attribs,
575 'controlName' => $name,
594 $params[
'controlName'] = $this->
getName() .
'_' . $params[
'var'];
595 $params[
'value'] = $this->
getVar( $params[
'var'] );
597 return $this->parent->getRadioSet( $params );
608 return $this->parent->setVarsFromRequest( $varNames, $this->
getName() .
'_' );
628 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
636 return $this->db->tableExists(
'cur', __METHOD__ ) ||
637 $this->db->tableExists(
'revision', __METHOD__ );
646 return Html::openElement(
'fieldset' ) .
647 Html::element(
'legend', [],
wfMessage(
'config-db-install-account' )->text() ) .
650 'config-db-username',
652 $this->parent->getHelpBox(
'config-db-install-username' )
656 'config-db-password',
658 $this->parent->getHelpBox(
'config-db-install-password' )
660 Html::closeElement(
'fieldset' );
681 $wrapperStyle = $this->
getVar(
'_SameAccount' ) ?
'display: none' :
'';
682 $s = Html::openElement(
'fieldset' ) .
683 Html::element(
'legend', [],
wfMessage(
'config-db-web-account' )->text() ) .
685 '_SameAccount',
'config-db-web-account-same',
686 [
'class' =>
'hideShowRadio',
'rel' =>
'dbOtherAccount' ]
688 Html::openElement(
'div', [
'id' =>
'dbOtherAccount',
'style' => $wrapperStyle ] ) .
689 $this->
getTextBox(
'wgDBuser',
'config-db-username' ) .
691 $this->parent->getHelpBox(
'config-db-web-help' );
692 if ( $noCreateMsg ) {
693 $s .= Html::warningBox(
wfMessage( $noCreateMsg )->plain(),
'config-warning-box' );
695 $s .= $this->
getCheckBox(
'_CreateDBAccount',
'config-db-web-create' );
697 $s .= Html::closeElement(
'div' ) . Html::closeElement(
'fieldset' );
709 [
'wgDBuser',
'wgDBpassword',
'_SameAccount',
'_CreateDBAccount' ]
712 if ( $this->
getVar(
'_SameAccount' ) ) {
713 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
714 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
717 if ( $this->
getVar(
'_CreateDBAccount' ) && strval( $this->
getVar(
'wgDBpassword' ) ) ==
'' ) {
734 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
736 if ( $this->db->selectRow(
'interwiki',
'1', [], __METHOD__ ) ) {
737 $status->warning(
'config-install-interwiki-exists' );
742 Wikimedia\suppressWarnings();
743 $rows = file(
"$IP/maintenance/interwiki.list",
744 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
745 Wikimedia\restoreWarnings();
750 foreach ( $rows as $row ) {
751 $row = preg_replace(
'/^\s*([^#]*?)\s*(#.*)?$/',
'\\1', $row );
756 $interwikis[] = array_combine(
757 [
'iw_prefix',
'iw_url',
'iw_local',
'iw_api',
'iw_wikiid' ],
761 $this->db->insert(
'interwiki', $interwikis, __METHOD__ );
767 return htmlspecialchars( $string );
array $globalNames
Array of MW configuration globals this class uses.
static newForDB(IMaintainableDatabase $db, $shared=false, Maintenance $maintenance=null)
static newFatal( $message,... $parameters)
Factory function for fatal errors.
static checkExtension( $name)
Convenience function.
doUpgrade()
Perform database upgrades.
Class for the core installer web interface.
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
checkPrerequisites()
Checks for installation prerequisites other than those checked by isCompiled()
getSchemaVars()
Override this to provide DBMS-specific schema variables, to be substituted into tables....
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
submitSettingsForm()
Set variables based on the request array, assuming it was submitted via the form return by getSetting...
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
getReadableName()
Get the internationalised name for this DBMS.
createTables()
Create database tables from scratch.
getInternalDefaults()
Get a name=>value map of internal variables used during installation.
getSqlFilePath( $db, $filename)
Return a path to the DBMS-specific SQL file if it exists, otherwise default SQL file.
getConnectForm()
Get HTML for a web form that configures this database.
getPasswordBox( $var, $label, $attribs=[], $helpData="")
Get a labelled password box to configure a local variable.
getText()
Get the text to display when reporting the error on the command line.
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
getUpdateKeysPath( $db)
Return a path to the DBMS-specific update key file, otherwise default to update-keys....
submitWebUserBox()
Submit the form from getWebUserBox().
static string $minimumVersion
Set by subclasses.
getName()
Return the internal name, e.g.
setupSchemaVars()
Set appropriate schema variables in the current database connection.
getSchemaPath( $db)
Return a path to the DBMS-specific schema file, otherwise default to tables.sql.
getWebUserBox( $noCreateMsg=false)
Get a standard web-user fieldset.
getRadioSet( $params)
Get a set of labelled radio buttons.
stepApplySourceFile( $sourceFileMethod, $stepName, $archiveTableMustNotExist=false)
Apply a SQL source file to the database as part of running an installation step.
getGlobalDefaults()
Get a name=>value map of MW configuration globals for the default values.
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
static newGood( $value=null)
Factory function for good results.
createExtensionTables()
Create the tables for each extension the user enabled.
submitInstallUserBox()
Submit a standard install user fieldset.
Base class for DBMS-specific installation helper classes.
getGlobalNames()
Get an array of MW configuration globals that will be configured by this class.
getSettingsForm()
Get HTML for a web form that retrieves settings used for installation.
openConnection()
Open a connection to the database using the administrative user/password currently defined in the ses...
static string $notMinimumVersionMessage
Set by subclasses.
enableLB()
Set up LBFactory so that wfGetDB() etc.
populateInterwikiTable()
Common function for databases that don't understand the MySQLish syntax of interwiki....
setVar( $name, $value)
Convenience alias for $this->parent->setVar()
getInstallUserBox()
Get a standard install-user fieldset.
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
static meetsMinimumRequirement( $serverVersion)
Whether the provided version meets the necessary requirements for this type.
WebInstaller $parent
The Installer object.
Database $db
The database connection.
setupDatabase()
Create the database and return a Status object indicating success or failure.
insertUpdateKeys()
Insert update keys into table to prevent running unneded updates.
array $internalDefaults
Internal variables for installation.
getCheckBox( $var, $label, $attribs=[], $helpData="")
Get a labelled checkbox to configure a local boolean variable.
__construct( $parent)
Construct and initialise parent.
needsUpgrade()
Determine whether an existing installation of MediaWiki is present in the configured administrative c...