MediaWiki  1.33.0
DatabaseInstaller.php
Go to the documentation of this file.
1 <?php
28 
35 abstract class DatabaseInstaller {
36 
44  public $parent;
45 
49  public static $minimumVersion;
50 
54  protected static $notMiniumumVerisonMessage;
55 
61  public $db = null;
62 
68  protected $internalDefaults = [];
69 
75  protected $globalNames = [];
76 
84  public static function meetsMinimumRequirement( $serverVersion ) {
85  if ( version_compare( $serverVersion, static::$minimumVersion ) < 0 ) {
86  return Status::newFatal(
87  static::$notMiniumumVerisonMessage, static::$minimumVersion, $serverVersion
88  );
89  }
90 
91  return Status::newGood();
92  }
93 
97  abstract public function getName();
98 
102  abstract public function isCompiled();
103 
109  public function checkPrerequisites() {
110  return Status::newGood();
111  }
112 
120  abstract public function getConnectForm();
121 
131  abstract public function submitConnectForm();
132 
140  public function getSettingsForm() {
141  return false;
142  }
143 
150  public function submitSettingsForm() {
151  return Status::newGood();
152  }
153 
162  abstract public function openConnection();
163 
170  abstract public function setupDatabase();
171 
181  public function getConnection() {
182  if ( $this->db ) {
183  return Status::newGood( $this->db );
184  }
185 
186  $status = $this->openConnection();
187  if ( $status->isOK() ) {
188  $this->db = $status->value;
189  // Enable autocommit
190  $this->db->clearFlag( DBO_TRX );
191  $this->db->commit( __METHOD__ );
192  }
193 
194  return $status;
195  }
196 
205  private function stepApplySourceFile(
206  $sourceFileMethod,
207  $stepName,
208  $archiveTableMustNotExist = false
209  ) {
210  $status = $this->getConnection();
211  if ( !$status->isOK() ) {
212  return $status;
213  }
214  $this->db->selectDB( $this->getVar( 'wgDBname' ) );
215 
216  if ( $archiveTableMustNotExist && $this->db->tableExists( 'archive', __METHOD__ ) ) {
217  $status->warning( "config-$stepName-tables-exist" );
218  $this->enableLB();
219 
220  return $status;
221  }
222 
223  $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
224  $this->db->begin( __METHOD__ );
225 
226  $error = $this->db->sourceFile(
227  call_user_func( [ $this, $sourceFileMethod ], $this->db )
228  );
229  if ( $error !== true ) {
230  $this->db->reportQueryError( $error, 0, '', __METHOD__ );
231  $this->db->rollback( __METHOD__ );
232  $status->fatal( "config-$stepName-tables-failed", $error );
233  } else {
234  $this->db->commit( __METHOD__ );
235  }
236  // Resume normal operations
237  if ( $status->isOK() ) {
238  $this->enableLB();
239  }
240 
241  return $status;
242  }
243 
249  public function createTables() {
250  return $this->stepApplySourceFile( 'getSchemaPath', 'install', true );
251  }
252 
258  public function insertUpdateKeys() {
259  return $this->stepApplySourceFile( 'getUpdateKeysPath', 'updates', false );
260  }
261 
270  private function getSqlFilePath( $db, $filename ) {
271  global $IP;
272 
273  $dbmsSpecificFilePath = "$IP/maintenance/" . $db->getType() . "/$filename";
274  if ( file_exists( $dbmsSpecificFilePath ) ) {
275  return $dbmsSpecificFilePath;
276  } else {
277  return "$IP/maintenance/$filename";
278  }
279  }
280 
288  public function getSchemaPath( $db ) {
289  return $this->getSqlFilePath( $db, 'tables.sql' );
290  }
291 
299  public function getUpdateKeysPath( $db ) {
300  return $this->getSqlFilePath( $db, 'update-keys.sql' );
301  }
302 
307  public function createExtensionTables() {
308  $status = $this->getConnection();
309  if ( !$status->isOK() ) {
310  return $status;
311  }
312 
313  // Now run updates to create tables for old extensions
314  DatabaseUpdater::newForDB( $this->db )->doUpdates( [ 'extensions' ] );
315 
316  return $status;
317  }
318 
324  abstract public function getLocalSettings();
325 
331  public function getSchemaVars() {
332  return [];
333  }
334 
341  public function setupSchemaVars() {
342  $status = $this->getConnection();
343  if ( $status->isOK() ) {
344  $status->value->setSchemaVars( $this->getSchemaVars() );
345  } else {
346  $msg = __METHOD__ . ': unexpected error while establishing'
347  . ' a database connection with message: '
348  . $status->getMessage()->plain();
349  throw new MWException( $msg );
350  }
351  }
352 
358  public function enableLB() {
359  $status = $this->getConnection();
360  if ( !$status->isOK() ) {
361  throw new MWException( __METHOD__ . ': unexpected DB connection error' );
362  }
363 
364  \MediaWiki\MediaWikiServices::resetGlobalInstance();
365  $services = \MediaWiki\MediaWikiServices::getInstance();
366 
367  $connection = $status->value;
368  $services->redefineService( 'DBLoadBalancerFactory', function () use ( $connection ) {
369  return LBFactorySingle::newFromConnection( $connection );
370  } );
371  }
372 
379  public function doUpgrade() {
380  $this->setupSchemaVars();
381  $this->enableLB();
382 
383  $ret = true;
384  ob_start( [ $this, 'outputHandler' ] );
385  $up = DatabaseUpdater::newForDB( $this->db );
386  try {
387  $up->doUpdates();
388  $up->purgeCache();
389  } catch ( MWException $e ) {
390  echo "\nAn error occurred:\n";
391  echo $e->getText();
392  $ret = false;
393  } catch ( Exception $e ) {
394  echo "\nAn error occurred:\n";
395  echo $e->getMessage();
396  $ret = false;
397  }
398  ob_end_flush();
399 
400  return $ret;
401  }
402 
408  public function preInstall() {
409  }
410 
414  public function preUpgrade() {
415  }
416 
421  public function getGlobalNames() {
422  return $this->globalNames;
423  }
424 
430  public function __construct( $parent ) {
431  $this->parent = $parent;
432  }
433 
441  protected static function checkExtension( $name ) {
442  return extension_loaded( $name );
443  }
444 
449  public function getReadableName() {
450  // Messages: config-type-mysql, config-type-postgres, config-type-sqlite,
451  // config-type-oracle
452  return wfMessage( 'config-type-' . $this->getName() )->text();
453  }
454 
459  public function getGlobalDefaults() {
460  $defaults = [];
461  foreach ( $this->getGlobalNames() as $var ) {
462  if ( isset( $GLOBALS[$var] ) ) {
463  $defaults[$var] = $GLOBALS[$var];
464  }
465  }
466  return $defaults;
467  }
468 
473  public function getInternalDefaults() {
475  }
476 
483  public function getVar( $var, $default = null ) {
484  $defaults = $this->getGlobalDefaults();
485  $internal = $this->getInternalDefaults();
486  if ( isset( $defaults[$var] ) ) {
487  $default = $defaults[$var];
488  } elseif ( isset( $internal[$var] ) ) {
489  $default = $internal[$var];
490  }
491 
492  return $this->parent->getVar( $var, $default );
493  }
494 
500  public function setVar( $name, $value ) {
501  $this->parent->setVar( $name, $value );
502  }
503 
513  public function getTextBox( $var, $label, $attribs = [], $helpData = "" ) {
514  $name = $this->getName() . '_' . $var;
515  $value = $this->getVar( $var );
516  if ( !isset( $attribs ) ) {
517  $attribs = [];
518  }
519 
520  return $this->parent->getTextBox( [
521  'var' => $var,
522  'label' => $label,
523  'attribs' => $attribs,
524  'controlName' => $name,
525  'value' => $value,
526  'help' => $helpData
527  ] );
528  }
529 
540  public function getPasswordBox( $var, $label, $attribs = [], $helpData = "" ) {
541  $name = $this->getName() . '_' . $var;
542  $value = $this->getVar( $var );
543  if ( !isset( $attribs ) ) {
544  $attribs = [];
545  }
546 
547  return $this->parent->getPasswordBox( [
548  'var' => $var,
549  'label' => $label,
550  'attribs' => $attribs,
551  'controlName' => $name,
552  'value' => $value,
553  'help' => $helpData
554  ] );
555  }
556 
566  public function getCheckBox( $var, $label, $attribs = [], $helpData = "" ) {
567  $name = $this->getName() . '_' . $var;
568  $value = $this->getVar( $var );
569 
570  return $this->parent->getCheckBox( [
571  'var' => $var,
572  'label' => $label,
573  'attribs' => $attribs,
574  'controlName' => $name,
575  'value' => $value,
576  'help' => $helpData
577  ] );
578  }
579 
592  public function getRadioSet( $params ) {
593  $params['controlName'] = $this->getName() . '_' . $params['var'];
594  $params['value'] = $this->getVar( $params['var'] );
595 
596  return $this->parent->getRadioSet( $params );
597  }
598 
606  public function setVarsFromRequest( $varNames ) {
607  return $this->parent->setVarsFromRequest( $varNames, $this->getName() . '_' );
608  }
609 
620  public function needsUpgrade() {
621  $status = $this->getConnection();
622  if ( !$status->isOK() ) {
623  return false;
624  }
625 
626  try {
627  $this->db->selectDB( $this->getVar( 'wgDBname' ) );
628  } catch ( DBConnectionError $e ) {
629  // Don't catch DBConnectionError
630  throw $e;
631  } catch ( DBExpectedError $e ) {
632  return false;
633  }
634 
635  return $this->db->tableExists( 'cur', __METHOD__ ) ||
636  $this->db->tableExists( 'revision', __METHOD__ );
637  }
638 
644  public function getInstallUserBox() {
645  return Html::openElement( 'fieldset' ) .
646  Html::element( 'legend', [], wfMessage( 'config-db-install-account' )->text() ) .
647  $this->getTextBox(
648  '_InstallUser',
649  'config-db-username',
650  [ 'dir' => 'ltr' ],
651  $this->parent->getHelpBox( 'config-db-install-username' )
652  ) .
653  $this->getPasswordBox(
654  '_InstallPassword',
655  'config-db-password',
656  [ 'dir' => 'ltr' ],
657  $this->parent->getHelpBox( 'config-db-install-password' )
658  ) .
659  Html::closeElement( 'fieldset' );
660  }
661 
666  public function submitInstallUserBox() {
667  $this->setVarsFromRequest( [ '_InstallUser', '_InstallPassword' ] );
668 
669  return Status::newGood();
670  }
671 
679  public function getWebUserBox( $noCreateMsg = false ) {
680  $wrapperStyle = $this->getVar( '_SameAccount' ) ? 'display: none' : '';
681  $s = Html::openElement( 'fieldset' ) .
682  Html::element( 'legend', [], wfMessage( 'config-db-web-account' )->text() ) .
683  $this->getCheckBox(
684  '_SameAccount', 'config-db-web-account-same',
685  [ 'class' => 'hideShowRadio', 'rel' => 'dbOtherAccount' ]
686  ) .
687  Html::openElement( 'div', [ 'id' => 'dbOtherAccount', 'style' => $wrapperStyle ] ) .
688  $this->getTextBox( 'wgDBuser', 'config-db-username' ) .
689  $this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
690  $this->parent->getHelpBox( 'config-db-web-help' );
691  if ( $noCreateMsg ) {
692  $s .= $this->parent->getWarningBox( wfMessage( $noCreateMsg )->plain() );
693  } else {
694  $s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' );
695  }
696  $s .= Html::closeElement( 'div' ) . Html::closeElement( 'fieldset' );
697 
698  return $s;
699  }
700 
706  public function submitWebUserBox() {
707  $this->setVarsFromRequest(
708  [ 'wgDBuser', 'wgDBpassword', '_SameAccount', '_CreateDBAccount' ]
709  );
710 
711  if ( $this->getVar( '_SameAccount' ) ) {
712  $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
713  $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
714  }
715 
716  if ( $this->getVar( '_CreateDBAccount' ) && strval( $this->getVar( 'wgDBpassword' ) ) == '' ) {
717  return Status::newFatal( 'config-db-password-empty', $this->getVar( 'wgDBuser' ) );
718  }
719 
720  return Status::newGood();
721  }
722 
728  public function populateInterwikiTable() {
729  $status = $this->getConnection();
730  if ( !$status->isOK() ) {
731  return $status;
732  }
733  $this->db->selectDB( $this->getVar( 'wgDBname' ) );
734 
735  if ( $this->db->selectRow( 'interwiki', '1', [], __METHOD__ ) ) {
736  $status->warning( 'config-install-interwiki-exists' );
737 
738  return $status;
739  }
740  global $IP;
741  Wikimedia\suppressWarnings();
742  $rows = file( "$IP/maintenance/interwiki.list",
743  FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES );
744  Wikimedia\restoreWarnings();
745  $interwikis = [];
746  if ( !$rows ) {
747  return Status::newFatal( 'config-install-interwiki-list' );
748  }
749  foreach ( $rows as $row ) {
750  $row = preg_replace( '/^\s*([^#]*?)\s*(#.*)?$/', '\\1', $row ); // strip comments - whee
751  if ( $row == "" ) {
752  continue;
753  }
754  $row .= "|";
755  $interwikis[] = array_combine(
756  [ 'iw_prefix', 'iw_url', 'iw_local', 'iw_api', 'iw_wikiid' ],
757  explode( '|', $row )
758  );
759  }
760  $this->db->insert( 'interwiki', $interwikis, __METHOD__ );
761 
762  return Status::newGood();
763  }
764 
765  public function outputHandler( $string ) {
766  return htmlspecialchars( $string );
767  }
768 }
$status
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition: hooks.txt:1266
DatabaseInstaller\$globalNames
array $globalNames
Array of MW configuration globals this class uses.
Definition: DatabaseInstaller.php:75
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:48
file
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
Definition: hooks.txt:91
DatabaseUpdater\newForDB
static newForDB(IMaintainableDatabase $db, $shared=false, Maintenance $maintenance=null)
Definition: DatabaseUpdater.php:191
DatabaseInstaller\checkExtension
static checkExtension( $name)
Convenience function.
Definition: DatabaseInstaller.php:441
DatabaseInstaller\doUpgrade
doUpgrade()
Perform database upgrades.
Definition: DatabaseInstaller.php:379
WebInstaller
Class for the core installer web interface.
Definition: WebInstaller.php:32
DatabaseInstaller\getConnection
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
Definition: DatabaseInstaller.php:181
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:68
$params
$params
Definition: styleTest.css.php:44
DatabaseInstaller\getTextBox
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
Definition: DatabaseInstaller.php:513
DatabaseInstaller\checkPrerequisites
checkPrerequisites()
Checks for installation prerequisites other than those checked by isCompiled()
Definition: DatabaseInstaller.php:109
DatabaseInstaller\getSchemaVars
getSchemaVars()
Override this to provide DBMS-specific schema variables, to be substituted into tables....
Definition: DatabaseInstaller.php:331
$s
$s
Definition: mergeMessageFileList.php:186
DatabaseInstaller\preUpgrade
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
Definition: DatabaseInstaller.php:414
DatabaseInstaller\preInstall
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
Definition: DatabaseInstaller.php:408
DatabaseInstaller\submitSettingsForm
submitSettingsForm()
Set variables based on the request array, assuming it was submitted via the form return by getSetting...
Definition: DatabaseInstaller.php:150
DatabaseInstaller\getLocalSettings
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
DBO_TRX
const DBO_TRX
Definition: defines.php:12
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
DatabaseInstaller\getReadableName
getReadableName()
Get the internationalised name for this DBMS.
Definition: DatabaseInstaller.php:449
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
DatabaseInstaller\createTables
createTables()
Create database tables from scratch.
Definition: DatabaseInstaller.php:249
DatabaseInstaller\getInternalDefaults
getInternalDefaults()
Get a name=>value map of internal variables used during installation.
Definition: DatabaseInstaller.php:473
DatabaseInstaller\getSqlFilePath
getSqlFilePath( $db, $filename)
Return a path to the DBMS-specific SQL file if it exists, otherwise default SQL file.
Definition: DatabaseInstaller.php:270
DatabaseInstaller\getConnectForm
getConnectForm()
Get HTML for a web form that configures this database.
MWException
MediaWiki exception.
Definition: MWException.php:26
DatabaseInstaller\getPasswordBox
getPasswordBox( $var, $label, $attribs=[], $helpData="")
Get a labelled password box to configure a local variable.
Definition: DatabaseInstaller.php:540
Wikimedia\Rdbms\LBFactorySingle
An LBFactory class that always returns a single database object.
Definition: LBFactorySingle.php:32
DatabaseInstaller\submitConnectForm
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
DatabaseInstaller\getUpdateKeysPath
getUpdateKeysPath( $db)
Return a path to the DBMS-specific update key file, otherwise default to update-keys....
Definition: DatabaseInstaller.php:299
DatabaseInstaller\submitWebUserBox
submitWebUserBox()
Submit the form from getWebUserBox().
Definition: DatabaseInstaller.php:706
DatabaseInstaller\$minimumVersion
static string $minimumVersion
Set by subclasses.
Definition: DatabaseInstaller.php:49
DatabaseInstaller\getName
getName()
Return the internal name, e.g.
DatabaseInstaller\outputHandler
outputHandler( $string)
Definition: DatabaseInstaller.php:765
$attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition: hooks.txt:1985
$IP
$IP
Definition: update.php:3
DatabaseInstaller\setupSchemaVars
setupSchemaVars()
Set appropriate schema variables in the current database connection.
Definition: DatabaseInstaller.php:341
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
DatabaseInstaller\getSchemaPath
getSchemaPath( $db)
Return a path to the DBMS-specific schema file, otherwise default to tables.sql.
Definition: DatabaseInstaller.php:288
DatabaseInstaller\getWebUserBox
getWebUserBox( $noCreateMsg=false)
Get a standard web-user fieldset.
Definition: DatabaseInstaller.php:679
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
DatabaseInstaller\getRadioSet
getRadioSet( $params)
Get a set of labelled radio buttons.
Definition: DatabaseInstaller.php:592
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
DatabaseInstaller\stepApplySourceFile
stepApplySourceFile( $sourceFileMethod, $stepName, $archiveTableMustNotExist=false)
Apply a SQL source file to the database as part of running an installation step.
Definition: DatabaseInstaller.php:205
DatabaseInstaller\getGlobalDefaults
getGlobalDefaults()
Get a name=>value map of MW configuration globals for the default values.
Definition: DatabaseInstaller.php:459
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2162
$value
$value
Definition: styleTest.css.php:49
DatabaseInstaller\getVar
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
Definition: DatabaseInstaller.php:483
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
DBO_DDLMODE
const DBO_DDLMODE
Definition: defines.php:16
DatabaseInstaller\createExtensionTables
createExtensionTables()
Create the tables for each extension the user enabled.
Definition: DatabaseInstaller.php:307
DatabaseInstaller\submitInstallUserBox
submitInstallUserBox()
Submit a standard install user fieldset.
Definition: DatabaseInstaller.php:666
DatabaseInstaller
Base class for DBMS-specific installation helper classes.
Definition: DatabaseInstaller.php:35
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:1985
plain
either a plain
Definition: hooks.txt:2046
DatabaseInstaller\getGlobalNames
getGlobalNames()
Get an array of MW configuration globals that will be configured by this class.
Definition: DatabaseInstaller.php:421
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
DatabaseInstaller\getSettingsForm
getSettingsForm()
Get HTML for a web form that retrieves settings used for installation.
Definition: DatabaseInstaller.php:140
$rows
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
Definition: hooks.txt:2636
Wikimedia\Rdbms\DBExpectedError
Base class for the more common types of database errors.
Definition: DBExpectedError.php:32
DatabaseInstaller\openConnection
openConnection()
Open a connection to the database using the administrative user/password currently defined in the ses...
DatabaseInstaller\enableLB
enableLB()
Set up LBFactory so that wfGetDB() etc.
Definition: DatabaseInstaller.php:358
DatabaseInstaller\populateInterwikiTable
populateInterwikiTable()
Common function for databases that don't understand the MySQLish syntax of interwiki....
Definition: DatabaseInstaller.php:728
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
DatabaseInstaller\setVar
setVar( $name, $value)
Convenience alias for $this->parent->setVar()
Definition: DatabaseInstaller.php:500
DatabaseInstaller\getInstallUserBox
getInstallUserBox()
Get a standard install-user fieldset.
Definition: DatabaseInstaller.php:644
DatabaseInstaller\setVarsFromRequest
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
Definition: DatabaseInstaller.php:606
Wikimedia\Rdbms\DBConnectionError
Definition: DBConnectionError.php:26
Wikimedia\Rdbms\IDatabase\getType
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
DatabaseInstaller\meetsMinimumRequirement
static meetsMinimumRequirement( $serverVersion)
Whether the provided version meets the necessary requirements for this type.
Definition: DatabaseInstaller.php:84
DatabaseInstaller\$parent
WebInstaller $parent
The Installer object.
Definition: DatabaseInstaller.php:44
DatabaseInstaller\isCompiled
isCompiled()
DatabaseInstaller\$db
Database $db
The database connection.
Definition: DatabaseInstaller.php:61
$services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2220
DatabaseInstaller\setupDatabase
setupDatabase()
Create the database and return a Status object indicating success or failure.
DatabaseInstaller\insertUpdateKeys
insertUpdateKeys()
Insert update keys into table to prevent running unneded updates.
Definition: DatabaseInstaller.php:258
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
DatabaseInstaller\$notMiniumumVerisonMessage
static string $notMiniumumVerisonMessage
Set by subclasses.
Definition: DatabaseInstaller.php:54
DatabaseInstaller\$internalDefaults
array $internalDefaults
Internal variables for installation.
Definition: DatabaseInstaller.php:68
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6
DatabaseInstaller\getCheckBox
getCheckBox( $var, $label, $attribs=[], $helpData="")
Get a labelled checkbox to configure a local boolean variable.
Definition: DatabaseInstaller.php:566
DatabaseInstaller\__construct
__construct( $parent)
Construct and initialise parent.
Definition: DatabaseInstaller.php:430
DatabaseInstaller\needsUpgrade
needsUpgrade()
Determine whether an existing installation of MediaWiki is present in the configured administrative c...
Definition: DatabaseInstaller.php:620