Go to the documentation of this file.
85 if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) {
87 static::$notMinimumVersionMessage, static::$minimumVersion, $serverVersion
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__ );
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() ) {
292 $dbmsSpecificFilePath =
"$IP/maintenance/" .
$db->
getType() .
"/$filename";
293 if ( file_exists( $dbmsSpecificFilePath ) ) {
294 return $dbmsSpecificFilePath;
296 return "$IP/maintenance/$filename";
342 if ( !$status->isOK() ) {
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' =>
function () use ( $connection ) {
406 return LBFactorySingle::newFromConnection( $connection );
422 ob_start( [ $this,
'outputHandler' ] );
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 );
505 if ( isset( $GLOBALS[$var] ) ) {
506 $defaults[$var] = $GLOBALS[$var];
526 public function getVar( $var, $default =
null ) {
529 if ( isset( $defaults[$var] ) ) {
530 $default = $defaults[$var];
531 } elseif ( isset( $internal[$var] ) ) {
532 $default = $internal[$var];
535 return $this->parent->getVar( $var, $default );
543 public function setVar( $name, $value ) {
544 $this->parent->setVar( $name, $value );
557 public function getTextBox( $var, $label, $attribs = [], $helpData =
"" ) {
558 $name = $this->
getName() .
'_' . $var;
559 $value = $this->
getVar( $var );
560 if ( !isset( $attribs ) ) {
564 return $this->parent->getTextBox( [
567 'attribs' => $attribs,
568 'controlName' => $name,
586 $name = $this->
getName() .
'_' . $var;
587 $value = $this->
getVar( $var );
588 if ( !isset( $attribs ) ) {
592 return $this->parent->getPasswordBox( [
595 'attribs' => $attribs,
596 'controlName' => $name,
611 public function getCheckBox( $var, $label, $attribs = [], $helpData =
"" ) {
612 $name = $this->
getName() .
'_' . $var;
613 $value = $this->
getVar( $var );
615 return $this->parent->getCheckBox( [
618 'attribs' => $attribs,
619 'controlName' => $name,
638 $params[
'controlName'] = $this->
getName() .
'_' . $params[
'var'];
639 $params[
'value'] = $this->
getVar( $params[
'var'] );
641 return $this->parent->getRadioSet( $params );
652 return $this->parent->setVarsFromRequest( $varNames, $this->
getName() .
'_' );
668 if ( !$status->isOK() ) {
673 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
681 return $this->db->tableExists(
'cur', __METHOD__ ) ||
682 $this->db->tableExists(
'revision', __METHOD__ );
696 'config-db-username',
698 $this->parent->getHelpBox(
'config-db-install-username' )
703 'config-db-password',
705 $this->parent->getHelpBox(
'config-db-install-password' )
728 $wrapperStyle = $this->
getVar(
'_SameAccount' ) ?
'display: none' :
'';
732 '_SameAccount',
'config-db-web-account-same',
733 [
'class' =>
'hideShowRadio',
'rel' =>
'dbOtherAccount' ]
735 Html::openElement(
'div', [
'id' =>
'dbOtherAccount',
'style' => $wrapperStyle ] ) .
736 $this->
getTextBox(
'wgDBuser',
'config-db-username' ) .
738 $this->parent->getHelpBox(
'config-db-web-help' );
739 if ( $noCreateMsg ) {
742 $s .= $this->
getCheckBox(
'_CreateDBAccount',
'config-db-web-create' );
756 [
'wgDBuser',
'wgDBpassword',
'_SameAccount',
'_CreateDBAccount' ]
759 if ( $this->
getVar(
'_SameAccount' ) ) {
760 $this->
setVar(
'wgDBuser', $this->
getVar(
'_InstallUser' ) );
761 $this->
setVar(
'wgDBpassword', $this->
getVar(
'_InstallPassword' ) );
764 if ( $this->
getVar(
'_CreateDBAccount' ) && strval( $this->
getVar(
'wgDBpassword' ) ) ==
'' ) {
779 if ( !$status->isOK() ) {
782 $this->db->selectDB( $this->
getVar(
'wgDBname' ) );
784 if ( $this->db->selectRow(
'interwiki',
'1', [], __METHOD__ ) ) {
785 $status->warning(
'config-install-interwiki-exists' );
790 Wikimedia\suppressWarnings();
791 $rows = file(
"$IP/maintenance/interwiki.list",
792 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
793 Wikimedia\restoreWarnings();
798 foreach ( $rows as $row ) {
799 $row = preg_replace(
'/^\s*([^#]*?)\s*(#.*)?$/',
'\\1', $row );
804 $interwikis[] = array_combine(
805 [
'iw_prefix',
'iw_url',
'iw_local',
'iw_api',
'iw_wikiid' ],
809 $this->db->insert(
'interwiki', $interwikis, __METHOD__ );
815 return htmlspecialchars( $string );
createManualTables()
Create database tables from scratch.
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.
getGeneratedSchemaPath( $db)
Return a path to the DBMS-specific automatically generated schema file.
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() Stable to override.
getSchemaVars()
Override this to provide DBMS-specific schema variables, to be substituted into tables....
static warningBox( $html, $className='')
Return a warning box.
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 from the automatically generated file Stable to override.
getInternalDefaults()
Get a name=>value map of internal variables used during installation.
static closeElement( $element)
Returns "</$element>".
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 Stable to override.
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 Stable to override.
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....
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
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.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
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...