85 if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) {
86 return Status::newFatal(
87 static::$notMinimumVersionMessage, static::$minimumVersion, $serverVersion
91 return Status::newGood();
111 return Status::newGood();
154 return Status::newGood();
188 return Status::newGood( $this->db );
192 if ( $status->isOK() ) {
193 $this->db = $status->value;
195 $this->db->clearFlag(
DBO_TRX );
196 $this->db->commit( __METHOD__ );
213 $tableThatMustNotExist =
false
216 if ( !$status->isOK() ) {
219 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
221 if ( $tableThatMustNotExist && $this->db->tableExists( $tableThatMustNotExist, __METHOD__ ) ) {
222 $status->warning(
"config-$stepName-tables-exist" );
229 $this->db->begin( __METHOD__ );
232 $error = $this->db->sourceFile(
233 call_user_func( [ $this, $sourceFileMethod ], $this->db )
235 if ( $error !==
true ) {
236 $this->db->reportQueryError( $error, 0,
'', __METHOD__ );
237 $this->db->rollback( __METHOD__ );
238 $status->fatal(
"config-$stepName-tables-failed", $error );
240 $this->db->commit( __METHOD__ );
243 if ( $status->isOK() ) {
291 $dbmsSpecificFilePath =
"$IP/maintenance/" .
$db->
getType() .
"/$filename";
292 if ( file_exists( $dbmsSpecificFilePath ) ) {
293 return $dbmsSpecificFilePath;
295 return "$IP/maintenance/$filename";
341 if ( !$status->isOK() ) {
346 $updater = DatabaseUpdater::newForDB( $this->db );
347 $updater->setAutoExtensionHookContainer( $this->parent->getAutoExtensionHookContainer() );
348 $updater->doUpdates( [
'extensions' ] );
380 if ( $status->isOK() ) {
384 $msg = __METHOD__ .
': unexpected error while establishing'
385 .
' a database connection with message: '
386 . $status->getMessage()->plain();
398 if ( !$status->isOK() ) {
399 throw new MWException( __METHOD__ .
': unexpected DB connection error' );
401 $connection = $status->value;
403 $this->parent->resetMediaWikiServices(
null, [
404 'DBLoadBalancerFactory' =>
static function () use ( $connection ) {
405 return LBFactorySingle::newFromConnection( $connection );
421 ob_start( [ $this,
'outputHandler' ] );
422 $up = DatabaseUpdater::newForDB( $this->db );
427 echo
"\nAn error occurred:\n";
430 }
catch ( Exception $e ) {
431 echo
"\nAn error occurred:\n";
432 echo $e->getMessage();
483 return extension_loaded( $name );
504 if ( isset( $GLOBALS[$var] ) ) {
505 $defaults[$var] = $GLOBALS[$var];
525 public function getVar( $var, $default =
null ) {
528 if ( isset( $defaults[$var] ) ) {
529 $default = $defaults[$var];
530 } elseif ( isset( $internal[$var] ) ) {
531 $default = $internal[$var];
534 return $this->parent->getVar( $var, $default );
542 public function setVar( $name, $value ) {
543 $this->parent->setVar( $name, $value );
556 public function getTextBox( $var, $label, $attribs = [], $helpData =
"" ) {
557 $name = $this->
getName() .
'_' . $var;
558 $value = $this->
getVar( $var );
559 if ( !isset( $attribs ) ) {
563 return $this->parent->getTextBox( [
566 'attribs' => $attribs,
567 'controlName' => $name,
585 $name = $this->
getName() .
'_' . $var;
586 $value = $this->
getVar( $var );
587 if ( !isset( $attribs ) ) {
591 return $this->parent->getPasswordBox( [
594 'attribs' => $attribs,
595 'controlName' => $name,
610 public function getCheckBox( $var, $label, $attribs = [], $helpData =
"" ) {
611 $name = $this->
getName() .
'_' . $var;
612 $value = $this->
getVar( $var );
614 return $this->parent->getCheckBox( [
617 'attribs' => $attribs,
618 'controlName' => $name,
637 $params[
'controlName'] = $this->
getName() .
'_' . $params[
'var'];
638 $params[
'value'] = $this->
getVar( $params[
'var'] );
640 return $this->parent->getRadioSet( $params );
651 return $this->parent->setVarsFromRequest( $varNames, $this->
getName() .
'_' );
667 if ( !$status->isOK() ) {
672 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
680 return $this->db->tableExists(
'cur', __METHOD__ ) ||
681 $this->db->tableExists(
'revision', __METHOD__ );
690 return Html::openElement(
'fieldset' ) .
691 Html::element(
'legend', [],
wfMessage(
'config-db-install-account' )->text() ) .
695 'config-db-username',
697 $this->parent->getHelpBox(
'config-db-install-username' )
702 'config-db-password',
704 $this->parent->getHelpBox(
'config-db-install-password' )
706 Html::closeElement(
'fieldset' );
716 return Status::newGood();
727 $wrapperStyle = $this->
getVar(
'_SameAccount' ) ?
'display: none' :
'';
728 $s = Html::openElement(
'fieldset' ) .
729 Html::element(
'legend', [],
wfMessage(
'config-db-web-account' )->text() ) .
731 '_SameAccount',
'config-db-web-account-same',
732 [
'class' =>
'hideShowRadio',
'rel' =>
'dbOtherAccount' ]
734 Html::openElement(
'div', [
'id' =>
'dbOtherAccount',
'style' => $wrapperStyle ] ) .
735 $this->
getTextBox(
'wgDBuser',
'config-db-username' ) .
737 $this->parent->getHelpBox(
'config-db-web-help' );
738 if ( $noCreateMsg ) {
739 $s .= Html::warningBox(
wfMessage( $noCreateMsg )->plain(),
'config-warning-box' );
741 $s .= $this->
getCheckBox(
'_CreateDBAccount',
'config-db-web-create' );
743 $s .= Html::closeElement(
'div' ) . Html::closeElement(
'fieldset' );
755 [
'wgDBuser',
'wgDBpassword',
'_SameAccount',
'_CreateDBAccount' ]
758 if ( $this->
getVar(
'_SameAccount' ) ) {
759 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
760 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
763 if ( $this->
getVar(
'_CreateDBAccount' ) && strval( $this->
getVar(
'wgDBpassword' ) ) ==
'' ) {
764 return Status::newFatal(
'config-db-password-empty', $this->
getVar(
'wgDBuser' ) );
767 return Status::newGood();
778 if ( !$status->isOK() ) {
781 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
783 if ( $this->db->selectRow(
'interwiki',
'1', [], __METHOD__ ) ) {
784 $status->warning(
'config-install-interwiki-exists' );
789 Wikimedia\suppressWarnings();
790 $rows = file(
"$IP/maintenance/interwiki.list",
791 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
792 Wikimedia\restoreWarnings();
795 return Status::newFatal(
'config-install-interwiki-list' );
797 foreach ( $rows as $row ) {
798 $row = preg_replace(
'/^\s*([^#]*?)\s*(#.*)?$/',
'\\1', $row );
803 $interwikis[] = array_combine(
804 [
'iw_prefix',
'iw_url',
'iw_local',
'iw_api',
'iw_wikiid' ],
808 $this->db->insert(
'interwiki', $interwikis, __METHOD__ );
810 return Status::newGood();
814 return htmlspecialchars( $string );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Base class for DBMS-specific installation helper classes.
getWebUserBox( $noCreateMsg=false)
Get a standard web-user fieldset.
submitWebUserBox()
Submit the form from getWebUserBox().
static checkExtension( $name)
Convenience function.
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
__construct( $parent)
Construct and initialise parent.
enableLB()
Set up LBFactory so that wfGetDB() etc.
getUpdateKeysPath( $db)
Return a path to the DBMS-specific update key file, otherwise default to update-keys....
getGlobalNames()
Get an array of MW configuration globals that will be configured by this class.
getReadableName()
Get the internationalised name for this DBMS.
WebInstaller $parent
The Installer object.
submitSettingsForm()
Set variables based on the request array, assuming it was submitted via the form return by getSetting...
Database $db
The database connection.
static meetsMinimumRequirement( $serverVersion)
Whether the provided version meets the necessary requirements for this type.
createExtensionTables()
Create the tables for each extension the user enabled.
getGeneratedSchemaPath( $db)
Return a path to the DBMS-specific automatically generated schema file.
static string $notMinimumVersionMessage
Set by subclasses.
setupDatabase()
Create the database and return a Status object indicating success or failure.
getPasswordBox( $var, $label, $attribs=[], $helpData="")
Get a labelled password box to configure a local variable.
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
getSettingsForm()
Get HTML for a web form that retrieves settings used for installation.
static string $minimumVersion
Set by subclasses.
needsUpgrade()
Determine whether an existing installation of MediaWiki is present in the configured administrative c...
getSqlFilePath( $db, $filename)
Return a path to the DBMS-specific SQL file if it exists, otherwise default SQL file.
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
getCheckBox( $var, $label, $attribs=[], $helpData="")
Get a labelled checkbox to configure a local boolean variable.
getSchemaPath( $db)
Return a path to the DBMS-specific schema file, otherwise default to tables.sql.
stepApplySourceFile( $sourceFileMethod, $stepName, $tableThatMustNotExist=false)
Apply a SQL source file to the database as part of running an installation step.
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
getSchemaVars()
Override this to provide DBMS-specific schema variables, to be substituted into tables....
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
createTables()
Create database tables from scratch from the automatically generated file.
populateInterwikiTable()
Common function for databases that don't understand the MySQLish syntax of interwiki....
array $internalDefaults
Internal variables for installation.
doUpgrade()
Perform database upgrades.
checkPrerequisites()
Checks for installation prerequisites other than those checked by isCompiled()
getInternalDefaults()
Get a name=>value map of internal variables used during installation.
setVar( $name, $value)
Convenience alias for $this->parent->setVar()
submitInstallUserBox()
Submit a standard install user fieldset.
getConnectForm()
Get HTML for a web form that configures this database.
openConnection()
Open a connection to the database using the administrative user/password currently defined in the ses...
getName()
Return the internal name, e.g.
array $globalNames
Array of MW configuration globals this class uses.
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
getGlobalDefaults()
Get a name=>value map of MW configuration globals for the default values.
createManualTables()
Create database tables from scratch.
getInstallUserBox()
Get a standard install-user fieldset.
insertUpdateKeys()
Insert update keys into table to prevent running unneeded updates.
setupSchemaVars()
Set appropriate schema variables in the current database connection.
getRadioSet( $params)
Get a set of labelled radio buttons.
getText()
Get the text to display when reporting the error on the command line.
Class for the core installer web interface.
foreach( $mmfl['setupFiles'] as $fileName) if($queue) if(empty( $mmfl['quiet'])) $s