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 $archiveTableMustNotExist =
false
216 if ( !$status->isOK() ) {
219 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
221 if ( $archiveTableMustNotExist && $this->db->tableExists(
'archive', __METHOD__ ) ) {
222 $status->warning(
"config-$stepName-tables-exist" );
229 $this->db->begin( __METHOD__ );
231 $error = $this->db->sourceFile(
232 call_user_func( [ $this, $sourceFileMethod ], $this->db )
234 if ( $error !==
true ) {
235 $this->db->reportQueryError( $error, 0,
'', __METHOD__ );
236 $this->db->rollback( __METHOD__ );
237 $status->fatal(
"config-$stepName-tables-failed", $error );
239 $this->db->commit( __METHOD__ );
242 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' =>
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 );
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 );
555 public function getTextBox( $var, $label, $attribs = [], $helpData =
"" ) {
556 $name = $this->
getName() .
'_' . $var;
557 $value = $this->
getVar( $var );
558 if ( !isset( $attribs ) ) {
562 return $this->parent->getTextBox( [
565 'attribs' => $attribs,
566 'controlName' => $name,
583 $name = $this->
getName() .
'_' . $var;
584 $value = $this->
getVar( $var );
585 if ( !isset( $attribs ) ) {
589 return $this->parent->getPasswordBox( [
592 'attribs' => $attribs,
593 'controlName' => $name,
608 public function getCheckBox( $var, $label, $attribs = [], $helpData =
"" ) {
609 $name = $this->
getName() .
'_' . $var;
610 $value = $this->
getVar( $var );
612 return $this->parent->getCheckBox( [
615 'attribs' => $attribs,
616 'controlName' => $name,
635 $params[
'controlName'] = $this->
getName() .
'_' . $params[
'var'];
636 $params[
'value'] = $this->
getVar( $params[
'var'] );
638 return $this->parent->getRadioSet( $params );
649 return $this->parent->setVarsFromRequest( $varNames, $this->
getName() .
'_' );
665 if ( !$status->isOK() ) {
670 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
678 return $this->db->tableExists(
'cur', __METHOD__ ) ||
679 $this->db->tableExists(
'revision', __METHOD__ );
688 return Html::openElement(
'fieldset' ) .
689 Html::element(
'legend', [],
wfMessage(
'config-db-install-account' )->text() ) .
692 'config-db-username',
694 $this->parent->getHelpBox(
'config-db-install-username' )
698 'config-db-password',
700 $this->parent->getHelpBox(
'config-db-install-password' )
702 Html::closeElement(
'fieldset' );
712 return Status::newGood();
723 $wrapperStyle = $this->
getVar(
'_SameAccount' ) ?
'display: none' :
'';
724 $s = Html::openElement(
'fieldset' ) .
725 Html::element(
'legend', [],
wfMessage(
'config-db-web-account' )->text() ) .
727 '_SameAccount',
'config-db-web-account-same',
728 [
'class' =>
'hideShowRadio',
'rel' =>
'dbOtherAccount' ]
730 Html::openElement(
'div', [
'id' =>
'dbOtherAccount',
'style' => $wrapperStyle ] ) .
731 $this->
getTextBox(
'wgDBuser',
'config-db-username' ) .
733 $this->parent->getHelpBox(
'config-db-web-help' );
734 if ( $noCreateMsg ) {
735 $s .= Html::warningBox(
wfMessage( $noCreateMsg )->plain(),
'config-warning-box' );
737 $s .= $this->
getCheckBox(
'_CreateDBAccount',
'config-db-web-create' );
739 $s .= Html::closeElement(
'div' ) . Html::closeElement(
'fieldset' );
751 [
'wgDBuser',
'wgDBpassword',
'_SameAccount',
'_CreateDBAccount' ]
754 if ( $this->
getVar(
'_SameAccount' ) ) {
755 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
756 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
759 if ( $this->
getVar(
'_CreateDBAccount' ) && strval( $this->
getVar(
'wgDBpassword' ) ) ==
'' ) {
760 return Status::newFatal(
'config-db-password-empty', $this->
getVar(
'wgDBuser' ) );
763 return Status::newGood();
774 if ( !$status->isOK() ) {
777 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
779 if ( $this->db->selectRow(
'interwiki',
'1', [], __METHOD__ ) ) {
780 $status->warning(
'config-install-interwiki-exists' );
785 Wikimedia\suppressWarnings();
786 $rows = file(
"$IP/maintenance/interwiki.list",
787 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
788 Wikimedia\restoreWarnings();
791 return Status::newFatal(
'config-install-interwiki-list' );
793 foreach ( $rows as $row ) {
794 $row = preg_replace(
'/^\s*([^#]*?)\s*(#.*)?$/',
'\\1', $row );
799 $interwikis[] = array_combine(
800 [
'iw_prefix',
'iw_url',
'iw_local',
'iw_api',
'iw_wikiid' ],
804 $this->db->insert(
'interwiki', $interwikis, __METHOD__ );
806 return Status::newGood();
810 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 Stable to override.
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 Stable to override.
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.
stepApplySourceFile( $sourceFileMethod, $stepName, $archiveTableMustNotExist=false)
Apply a SQL source file to the database as part of running an installation step.
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 Stable to override.
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() Stable to override.
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 unneded 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.