24use Wikimedia\AtEase\AtEase;
86 if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) {
87 return Status::newFatal(
88 static::$notMinimumVersionMessage, static::$minimumVersion, $serverVersion
92 return Status::newGood();
112 return Status::newGood();
155 return Status::newGood();
189 return Status::newGood( $this->db );
193 if ( $status->isOK() ) {
194 $this->db = $status->value;
196 $this->db->clearFlag(
DBO_TRX );
197 $this->db->commit( __METHOD__ );
214 $tableThatMustNotExist =
false
217 if ( !$status->isOK() ) {
220 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
222 if ( $tableThatMustNotExist && $this->db->tableExists( $tableThatMustNotExist, __METHOD__ ) ) {
223 $status->warning(
"config-$stepName-tables-exist" );
230 $this->db->begin( __METHOD__ );
233 $error = $this->db->sourceFile(
234 call_user_func( [ $this, $sourceFileMethod ], $this->db )
236 if ( $error !==
true ) {
237 $this->db->reportQueryError( $error, 0,
'', __METHOD__ );
238 $this->db->rollback( __METHOD__ );
239 $status->fatal(
"config-$stepName-tables-failed", $error );
241 $this->db->commit( __METHOD__ );
244 if ( $status->isOK() ) {
292 $dbmsSpecificFilePath =
"$IP/maintenance/" .
$db->
getType() .
"/$filename";
293 if ( file_exists( $dbmsSpecificFilePath ) ) {
294 return $dbmsSpecificFilePath;
296 return "$IP/maintenance/$filename";
342 if ( !$status->isOK() ) {
347 $updater = DatabaseUpdater::newForDB( $this->db );
348 $updater->setAutoExtensionHookContainer( $this->parent->getAutoExtensionHookContainer() );
349 $updater->doUpdates( [
'extensions' ] );
381 if ( $status->isOK() ) {
385 $msg = __METHOD__ .
': unexpected error while establishing'
386 .
' a database connection with message: '
387 . $status->getMessage()->plain();
399 if ( !$status->isOK() ) {
400 throw new MWException( __METHOD__ .
': unexpected DB connection error' );
402 $connection = $status->value;
404 $this->parent->resetMediaWikiServices(
null, [
405 'DBLoadBalancerFactory' =>
static function () use ( $connection ) {
406 return LBFactorySingle::newFromConnection( $connection );
422 ob_start( [ $this,
'outputHandler' ] );
423 $up = DatabaseUpdater::newForDB( $this->db );
428 echo
"\nAn error occurred:\n";
431 }
catch ( Exception $e ) {
432 echo
"\nAn error occurred:\n";
433 echo $e->getMessage();
484 return extension_loaded( $name );
506 if ( isset( $GLOBALS[$var] ) ) {
507 $defaults[$var] = $GLOBALS[$var];
527 public function getVar( $var, $default =
null ) {
530 if ( isset( $defaults[$var] ) ) {
531 $default = $defaults[$var];
532 } elseif ( isset( $internal[$var] ) ) {
533 $default = $internal[$var];
536 return $this->parent->getVar( $var, $default );
544 public function setVar( $name, $value ) {
545 $this->parent->setVar( $name, $value );
558 public function getTextBox( $var, $label, $attribs = [], $helpData =
"" ) {
559 $name = $this->
getName() .
'_' . $var;
560 $value = $this->
getVar( $var );
561 if ( !isset( $attribs ) ) {
565 return $this->parent->getTextBox( [
568 'attribs' => $attribs,
569 'controlName' => $name,
587 $name = $this->
getName() .
'_' . $var;
588 $value = $this->
getVar( $var );
589 if ( !isset( $attribs ) ) {
593 return $this->parent->getPasswordBox( [
596 'attribs' => $attribs,
597 'controlName' => $name,
612 public function getCheckBox( $var, $label, $attribs = [], $helpData =
"" ) {
613 $name = $this->
getName() .
'_' . $var;
614 $value = $this->
getVar( $var );
616 return $this->parent->getCheckBox( [
619 'attribs' => $attribs,
620 'controlName' => $name,
639 $params[
'controlName'] = $this->
getName() .
'_' . $params[
'var'];
640 $params[
'value'] = $this->
getVar( $params[
'var'] );
642 return $this->parent->getRadioSet( $params );
653 return $this->parent->setVarsFromRequest( $varNames, $this->
getName() .
'_' );
669 if ( !$status->isOK() ) {
674 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
682 return $this->db->tableExists(
'cur', __METHOD__ ) ||
683 $this->db->tableExists(
'revision', __METHOD__ );
692 return Html::openElement(
'fieldset' ) .
693 Html::element(
'legend', [],
wfMessage(
'config-db-install-account' )->text() ) .
697 'config-db-username',
699 $this->parent->getHelpBox(
'config-db-install-username' )
704 'config-db-password',
706 $this->parent->getHelpBox(
'config-db-install-password' )
708 Html::closeElement(
'fieldset' );
718 return Status::newGood();
729 $wrapperStyle = $this->
getVar(
'_SameAccount' ) ?
'display: none' :
'';
730 $s = Html::openElement(
'fieldset' ) .
731 Html::element(
'legend', [],
wfMessage(
'config-db-web-account' )->text() ) .
733 '_SameAccount',
'config-db-web-account-same',
734 [
'class' =>
'hideShowRadio',
'rel' =>
'dbOtherAccount' ]
736 Html::openElement(
'div', [
'id' =>
'dbOtherAccount',
'style' => $wrapperStyle ] ) .
737 $this->
getTextBox(
'wgDBuser',
'config-db-username' ) .
739 $this->parent->getHelpBox(
'config-db-web-help' );
740 if ( $noCreateMsg ) {
741 $s .= Html::warningBox(
wfMessage( $noCreateMsg )->plain(),
'config-warning-box' );
743 $s .= $this->
getCheckBox(
'_CreateDBAccount',
'config-db-web-create' );
745 $s .= Html::closeElement(
'div' ) . Html::closeElement(
'fieldset' );
757 [
'wgDBuser',
'wgDBpassword',
'_SameAccount',
'_CreateDBAccount' ]
760 if ( $this->
getVar(
'_SameAccount' ) ) {
761 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
762 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
765 if ( $this->
getVar(
'_CreateDBAccount' ) && strval( $this->
getVar(
'wgDBpassword' ) ) ==
'' ) {
766 return Status::newFatal(
'config-db-password-empty', $this->
getVar(
'wgDBuser' ) );
769 return Status::newGood();
780 if ( !$status->isOK() ) {
783 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
785 if ( $this->db->selectRow(
'interwiki',
'1', [], __METHOD__ ) ) {
786 $status->warning(
'config-install-interwiki-exists' );
791 AtEase::suppressWarnings();
792 $rows = file(
"$IP/maintenance/interwiki.list",
793 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
794 AtEase::restoreWarnings();
797 return Status::newFatal(
'config-install-interwiki-list' );
799 foreach ( $rows as $row ) {
800 $row = preg_replace(
'/^\s*([^#]*?)\s*(#.*)?$/',
'\\1', $row );
805 $interwikis[] = array_combine(
806 [
'iw_prefix',
'iw_url',
'iw_local',
'iw_api',
'iw_wikiid' ],
810 $this->db->insert(
'interwiki', $interwikis, __METHOD__ );
812 return Status::newGood();
816 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