MediaWiki  1.29.1
MysqlInstaller.php
Go to the documentation of this file.
1 <?php
27 
35 
36  protected $globalNames = [
37  'wgDBserver',
38  'wgDBname',
39  'wgDBuser',
40  'wgDBpassword',
41  'wgDBprefix',
42  'wgDBTableOptions',
43  'wgDBmysql5',
44  ];
45 
46  protected $internalDefaults = [
47  '_MysqlEngine' => 'InnoDB',
48  '_MysqlCharset' => 'binary',
49  '_InstallUser' => 'root',
50  ];
51 
52  public $supportedEngines = [ 'InnoDB', 'MyISAM' ];
53 
54  public $minimumVersion = '5.0.3';
55 
56  public $webUserPrivs = [
57  'DELETE',
58  'INSERT',
59  'SELECT',
60  'UPDATE',
61  'CREATE TEMPORARY TABLES',
62  ];
63 
67  public function getName() {
68  return 'mysql';
69  }
70 
74  public function isCompiled() {
75  return self::checkExtension( 'mysql' ) || self::checkExtension( 'mysqli' );
76  }
77 
81  public function getConnectForm() {
82  return $this->getTextBox(
83  'wgDBserver',
84  'config-db-host',
85  [],
86  $this->parent->getHelpBox( 'config-db-host-help' )
87  ) .
88  Html::openElement( 'fieldset' ) .
89  Html::element( 'legend', [], wfMessage( 'config-db-wiki-settings' )->text() ) .
90  $this->getTextBox( 'wgDBname', 'config-db-name', [ 'dir' => 'ltr' ],
91  $this->parent->getHelpBox( 'config-db-name-help' ) ) .
92  $this->getTextBox( 'wgDBprefix', 'config-db-prefix', [ 'dir' => 'ltr' ],
93  $this->parent->getHelpBox( 'config-db-prefix-help' ) ) .
94  Html::closeElement( 'fieldset' ) .
95  $this->getInstallUserBox();
96  }
97 
98  public function submitConnectForm() {
99  // Get variables from the request.
100  $newValues = $this->setVarsFromRequest( [ 'wgDBserver', 'wgDBname', 'wgDBprefix' ] );
101 
102  // Validate them.
104  if ( !strlen( $newValues['wgDBserver'] ) ) {
105  $status->fatal( 'config-missing-db-host' );
106  }
107  if ( !strlen( $newValues['wgDBname'] ) ) {
108  $status->fatal( 'config-missing-db-name' );
109  } elseif ( !preg_match( '/^[a-z0-9+_-]+$/i', $newValues['wgDBname'] ) ) {
110  $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
111  }
112  if ( !preg_match( '/^[a-z0-9_-]*$/i', $newValues['wgDBprefix'] ) ) {
113  $status->fatal( 'config-invalid-db-prefix', $newValues['wgDBprefix'] );
114  }
115  if ( !$status->isOK() ) {
116  return $status;
117  }
118 
119  // Submit user box
120  $status = $this->submitInstallUserBox();
121  if ( !$status->isOK() ) {
122  return $status;
123  }
124 
125  // Try to connect
126  $status = $this->getConnection();
127  if ( !$status->isOK() ) {
128  return $status;
129  }
133  $conn = $status->value;
134 
135  // Check version
136  $version = $conn->getServerVersion();
137  if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
138  return Status::newFatal( 'config-mysql-old', $this->minimumVersion, $version );
139  }
140 
141  return $status;
142  }
143 
147  public function openConnection() {
149  try {
150  $db = Database::factory( 'mysql', [
151  'host' => $this->getVar( 'wgDBserver' ),
152  'user' => $this->getVar( '_InstallUser' ),
153  'password' => $this->getVar( '_InstallPassword' ),
154  'dbname' => false,
155  'flags' => 0,
156  'tablePrefix' => $this->getVar( 'wgDBprefix' ) ] );
157  $status->value = $db;
158  } catch ( DBConnectionError $e ) {
159  $status->fatal( 'config-connection-error', $e->getMessage() );
160  }
161 
162  return $status;
163  }
164 
165  public function preUpgrade() {
167 
168  $status = $this->getConnection();
169  if ( !$status->isOK() ) {
170  $this->parent->showStatusError( $status );
171 
172  return;
173  }
177  $conn = $status->value;
178  $conn->selectDB( $this->getVar( 'wgDBname' ) );
179 
180  # Determine existing default character set
181  if ( $conn->tableExists( "revision", __METHOD__ ) ) {
182  $revision = $this->escapeLikeInternal( $this->getVar( 'wgDBprefix' ) . 'revision', '\\' );
183  $res = $conn->query( "SHOW TABLE STATUS LIKE '$revision'", __METHOD__ );
184  $row = $conn->fetchObject( $res );
185  if ( !$row ) {
186  $this->parent->showMessage( 'config-show-table-status' );
187  $existingSchema = false;
188  $existingEngine = false;
189  } else {
190  if ( preg_match( '/^latin1/', $row->Collation ) ) {
191  $existingSchema = 'latin1';
192  } elseif ( preg_match( '/^utf8/', $row->Collation ) ) {
193  $existingSchema = 'utf8';
194  } elseif ( preg_match( '/^binary/', $row->Collation ) ) {
195  $existingSchema = 'binary';
196  } else {
197  $existingSchema = false;
198  $this->parent->showMessage( 'config-unknown-collation' );
199  }
200  if ( isset( $row->Engine ) ) {
201  $existingEngine = $row->Engine;
202  } else {
203  $existingEngine = $row->Type;
204  }
205  }
206  } else {
207  $existingSchema = false;
208  $existingEngine = false;
209  }
210 
211  if ( $existingSchema && $existingSchema != $this->getVar( '_MysqlCharset' ) ) {
212  $this->setVar( '_MysqlCharset', $existingSchema );
213  }
214  if ( $existingEngine && $existingEngine != $this->getVar( '_MysqlEngine' ) ) {
215  $this->setVar( '_MysqlEngine', $existingEngine );
216  }
217 
218  # Normal user and password are selected after this step, so for now
219  # just copy these two
220  $wgDBuser = $this->getVar( '_InstallUser' );
221  $wgDBpassword = $this->getVar( '_InstallPassword' );
222  }
223 
228  protected function escapeLikeInternal( $s, $escapeChar = '`' ) {
229  return str_replace( [ $escapeChar, '%', '_' ],
230  [ "{$escapeChar}{$escapeChar}", "{$escapeChar}%", "{$escapeChar}_" ],
231  $s );
232  }
233 
239  public function getEngines() {
240  $status = $this->getConnection();
241 
245  $conn = $status->value;
246 
247  $engines = [];
248  $res = $conn->query( 'SHOW ENGINES', __METHOD__ );
249  foreach ( $res as $row ) {
250  if ( $row->Support == 'YES' || $row->Support == 'DEFAULT' ) {
251  $engines[] = $row->Engine;
252  }
253  }
254  $engines = array_intersect( $this->supportedEngines, $engines );
255 
256  return $engines;
257  }
258 
264  public function getCharsets() {
265  return [ 'binary', 'utf8' ];
266  }
267 
273  public function canCreateAccounts() {
274  $status = $this->getConnection();
275  if ( !$status->isOK() ) {
276  return false;
277  }
279  $conn = $status->value;
280 
281  // Get current account name
282  $currentName = $conn->selectField( '', 'CURRENT_USER()', '', __METHOD__ );
283  $parts = explode( '@', $currentName );
284  if ( count( $parts ) != 2 ) {
285  return false;
286  }
287  $quotedUser = $conn->addQuotes( $parts[0] ) .
288  '@' . $conn->addQuotes( $parts[1] );
289 
290  // The user needs to have INSERT on mysql.* to be able to CREATE USER
291  // The grantee will be double-quoted in this query, as required
292  $res = $conn->select( 'INFORMATION_SCHEMA.USER_PRIVILEGES', '*',
293  [ 'GRANTEE' => $quotedUser ], __METHOD__ );
294  $insertMysql = false;
295  $grantOptions = array_flip( $this->webUserPrivs );
296  foreach ( $res as $row ) {
297  if ( $row->PRIVILEGE_TYPE == 'INSERT' ) {
298  $insertMysql = true;
299  }
300  if ( $row->IS_GRANTABLE ) {
301  unset( $grantOptions[$row->PRIVILEGE_TYPE] );
302  }
303  }
304 
305  // Check for DB-specific privs for mysql.*
306  if ( !$insertMysql ) {
307  $row = $conn->selectRow( 'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES', '*',
308  [
309  'GRANTEE' => $quotedUser,
310  'TABLE_SCHEMA' => 'mysql',
311  'PRIVILEGE_TYPE' => 'INSERT',
312  ], __METHOD__ );
313  if ( $row ) {
314  $insertMysql = true;
315  }
316  }
317 
318  if ( !$insertMysql ) {
319  return false;
320  }
321 
322  // Check for DB-level grant options
323  $res = $conn->select( 'INFORMATION_SCHEMA.SCHEMA_PRIVILEGES', '*',
324  [
325  'GRANTEE' => $quotedUser,
326  'IS_GRANTABLE' => 1,
327  ], __METHOD__ );
328  foreach ( $res as $row ) {
329  $regex = $this->likeToRegex( $row->TABLE_SCHEMA );
330  if ( preg_match( $regex, $this->getVar( 'wgDBname' ) ) ) {
331  unset( $grantOptions[$row->PRIVILEGE_TYPE] );
332  }
333  }
334  if ( count( $grantOptions ) ) {
335  // Can't grant everything
336  return false;
337  }
338 
339  return true;
340  }
341 
346  protected function likeToRegex( $wildcard ) {
347  $r = preg_quote( $wildcard, '/' );
348  $r = strtr( $r, [
349  '%' => '.*',
350  '_' => '.'
351  ] );
352  return "/$r/s";
353  }
354 
358  public function getSettingsForm() {
359  if ( $this->canCreateAccounts() ) {
360  $noCreateMsg = false;
361  } else {
362  $noCreateMsg = 'config-db-web-no-create-privs';
363  }
364  $s = $this->getWebUserBox( $noCreateMsg );
365 
366  // Do engine selector
367  $engines = $this->getEngines();
368  // If the current default engine is not supported, use an engine that is
369  if ( !in_array( $this->getVar( '_MysqlEngine' ), $engines ) ) {
370  $this->setVar( '_MysqlEngine', reset( $engines ) );
371  }
372 
373  $s .= Xml::openElement( 'div', [
374  'id' => 'dbMyisamWarning'
375  ] );
376  $myisamWarning = 'config-mysql-myisam-dep';
377  if ( count( $engines ) === 1 ) {
378  $myisamWarning = 'config-mysql-only-myisam-dep';
379  }
380  $s .= $this->parent->getWarningBox( wfMessage( $myisamWarning )->text() );
381  $s .= Xml::closeElement( 'div' );
382 
383  if ( $this->getVar( '_MysqlEngine' ) != 'MyISAM' ) {
384  $s .= Xml::openElement( 'script' );
385  $s .= '$(\'#dbMyisamWarning\').hide();';
386  $s .= Xml::closeElement( 'script' );
387  }
388 
389  if ( count( $engines ) >= 2 ) {
390  // getRadioSet() builds a set of labeled radio buttons.
391  // For grep: The following messages are used as the item labels:
392  // config-mysql-innodb, config-mysql-myisam
393  $s .= $this->getRadioSet( [
394  'var' => '_MysqlEngine',
395  'label' => 'config-mysql-engine',
396  'itemLabelPrefix' => 'config-mysql-',
397  'values' => $engines,
398  'itemAttribs' => [
399  'MyISAM' => [
400  'class' => 'showHideRadio',
401  'rel' => 'dbMyisamWarning'
402  ],
403  'InnoDB' => [
404  'class' => 'hideShowRadio',
405  'rel' => 'dbMyisamWarning'
406  ]
407  ]
408  ] );
409  $s .= $this->parent->getHelpBox( 'config-mysql-engine-help' );
410  }
411 
412  // If the current default charset is not supported, use a charset that is
413  $charsets = $this->getCharsets();
414  if ( !in_array( $this->getVar( '_MysqlCharset' ), $charsets ) ) {
415  $this->setVar( '_MysqlCharset', reset( $charsets ) );
416  }
417 
418  // Do charset selector
419  if ( count( $charsets ) >= 2 ) {
420  // getRadioSet() builds a set of labeled radio buttons.
421  // For grep: The following messages are used as the item labels:
422  // config-mysql-binary, config-mysql-utf8
423  $s .= $this->getRadioSet( [
424  'var' => '_MysqlCharset',
425  'label' => 'config-mysql-charset',
426  'itemLabelPrefix' => 'config-mysql-',
427  'values' => $charsets
428  ] );
429  $s .= $this->parent->getHelpBox( 'config-mysql-charset-help' );
430  }
431 
432  return $s;
433  }
434 
438  public function submitSettingsForm() {
439  $this->setVarsFromRequest( [ '_MysqlEngine', '_MysqlCharset' ] );
440  $status = $this->submitWebUserBox();
441  if ( !$status->isOK() ) {
442  return $status;
443  }
444 
445  // Validate the create checkbox
446  $canCreate = $this->canCreateAccounts();
447  if ( !$canCreate ) {
448  $this->setVar( '_CreateDBAccount', false );
449  $create = false;
450  } else {
451  $create = $this->getVar( '_CreateDBAccount' );
452  }
453 
454  if ( !$create ) {
455  // Test the web account
456  try {
457  Database::factory( 'mysql', [
458  'host' => $this->getVar( 'wgDBserver' ),
459  'user' => $this->getVar( 'wgDBuser' ),
460  'password' => $this->getVar( 'wgDBpassword' ),
461  'dbname' => false,
462  'flags' => 0,
463  'tablePrefix' => $this->getVar( 'wgDBprefix' )
464  ] );
465  } catch ( DBConnectionError $e ) {
466  return Status::newFatal( 'config-connection-error', $e->getMessage() );
467  }
468  }
469 
470  // Validate engines and charsets
471  // This is done pre-submit already so it's just for security
472  $engines = $this->getEngines();
473  if ( !in_array( $this->getVar( '_MysqlEngine' ), $engines ) ) {
474  $this->setVar( '_MysqlEngine', reset( $engines ) );
475  }
476  $charsets = $this->getCharsets();
477  if ( !in_array( $this->getVar( '_MysqlCharset' ), $charsets ) ) {
478  $this->setVar( '_MysqlCharset', reset( $charsets ) );
479  }
480 
481  return Status::newGood();
482  }
483 
484  public function preInstall() {
485  # Add our user callback to installSteps, right before the tables are created.
486  $callback = [
487  'name' => 'user',
488  'callback' => [ $this, 'setupUser' ],
489  ];
490  $this->parent->addInstallStep( $callback, 'tables' );
491  }
492 
496  public function setupDatabase() {
497  $status = $this->getConnection();
498  if ( !$status->isOK() ) {
499  return $status;
500  }
502  $conn = $status->value;
503  $dbName = $this->getVar( 'wgDBname' );
504  if ( !$conn->selectDB( $dbName ) ) {
505  $conn->query(
506  "CREATE DATABASE " . $conn->addIdentifierQuotes( $dbName ) . "CHARACTER SET utf8",
507  __METHOD__
508  );
509  $conn->selectDB( $dbName );
510  }
511  $this->setupSchemaVars();
512 
513  return $status;
514  }
515 
519  public function setupUser() {
520  $dbUser = $this->getVar( 'wgDBuser' );
521  if ( $dbUser == $this->getVar( '_InstallUser' ) ) {
522  return Status::newGood();
523  }
524  $status = $this->getConnection();
525  if ( !$status->isOK() ) {
526  return $status;
527  }
528 
529  $this->setupSchemaVars();
530  $dbName = $this->getVar( 'wgDBname' );
531  $this->db->selectDB( $dbName );
532  $server = $this->getVar( 'wgDBserver' );
533  $password = $this->getVar( 'wgDBpassword' );
534  $grantableNames = [];
535 
536  if ( $this->getVar( '_CreateDBAccount' ) ) {
537  // Before we blindly try to create a user that already has access,
538  try { // first attempt to connect to the database
539  Database::factory( 'mysql', [
540  'host' => $server,
541  'user' => $dbUser,
542  'password' => $password,
543  'dbname' => false,
544  'flags' => 0,
545  'tablePrefix' => $this->getVar( 'wgDBprefix' )
546  ] );
547  $grantableNames[] = $this->buildFullUserName( $dbUser, $server );
548  $tryToCreate = false;
549  } catch ( DBConnectionError $e ) {
550  $tryToCreate = true;
551  }
552  } else {
553  $grantableNames[] = $this->buildFullUserName( $dbUser, $server );
554  $tryToCreate = false;
555  }
556 
557  if ( $tryToCreate ) {
558  $createHostList = [
559  $server,
560  'localhost',
561  'localhost.localdomain',
562  '%'
563  ];
564 
565  $createHostList = array_unique( $createHostList );
566  $escPass = $this->db->addQuotes( $password );
567 
568  foreach ( $createHostList as $host ) {
569  $fullName = $this->buildFullUserName( $dbUser, $host );
570  if ( !$this->userDefinitelyExists( $host, $dbUser ) ) {
571  try {
572  $this->db->begin( __METHOD__ );
573  $this->db->query( "CREATE USER $fullName IDENTIFIED BY $escPass", __METHOD__ );
574  $this->db->commit( __METHOD__ );
575  $grantableNames[] = $fullName;
576  } catch ( DBQueryError $dqe ) {
577  if ( $this->db->lastErrno() == 1396 /* ER_CANNOT_USER */ ) {
578  // User (probably) already exists
579  $this->db->rollback( __METHOD__ );
580  $status->warning( 'config-install-user-alreadyexists', $dbUser );
581  $grantableNames[] = $fullName;
582  break;
583  } else {
584  // If we couldn't create for some bizzare reason and the
585  // user probably doesn't exist, skip the grant
586  $this->db->rollback( __METHOD__ );
587  $status->warning( 'config-install-user-create-failed', $dbUser, $dqe->getMessage() );
588  }
589  }
590  } else {
591  $status->warning( 'config-install-user-alreadyexists', $dbUser );
592  $grantableNames[] = $fullName;
593  break;
594  }
595  }
596  }
597 
598  // Try to grant to all the users we know exist or we were able to create
599  $dbAllTables = $this->db->addIdentifierQuotes( $dbName ) . '.*';
600  foreach ( $grantableNames as $name ) {
601  try {
602  $this->db->begin( __METHOD__ );
603  $this->db->query( "GRANT ALL PRIVILEGES ON $dbAllTables TO $name", __METHOD__ );
604  $this->db->commit( __METHOD__ );
605  } catch ( DBQueryError $dqe ) {
606  $this->db->rollback( __METHOD__ );
607  $status->fatal( 'config-install-user-grant-failed', $dbUser, $dqe->getMessage() );
608  }
609  }
610 
611  return $status;
612  }
613 
620  private function buildFullUserName( $name, $host ) {
621  return $this->db->addQuotes( $name ) . '@' . $this->db->addQuotes( $host );
622  }
623 
631  private function userDefinitelyExists( $host, $user ) {
632  try {
633  $res = $this->db->selectRow( 'mysql.user', [ 'Host', 'User' ],
634  [ 'Host' => $host, 'User' => $user ], __METHOD__ );
635 
636  return (bool)$res;
637  } catch ( DBQueryError $dqe ) {
638  return false;
639  }
640  }
641 
648  protected function getTableOptions() {
649  $options = [];
650  if ( $this->getVar( '_MysqlEngine' ) !== null ) {
651  $options[] = "ENGINE=" . $this->getVar( '_MysqlEngine' );
652  }
653  if ( $this->getVar( '_MysqlCharset' ) !== null ) {
654  $options[] = 'DEFAULT CHARSET=' . $this->getVar( '_MysqlCharset' );
655  }
656 
657  return implode( ', ', $options );
658  }
659 
665  public function getSchemaVars() {
666  return [
667  'wgDBTableOptions' => $this->getTableOptions(),
668  'wgDBname' => $this->getVar( 'wgDBname' ),
669  'wgDBuser' => $this->getVar( 'wgDBuser' ),
670  'wgDBpassword' => $this->getVar( 'wgDBpassword' ),
671  ];
672  }
673 
674  public function getLocalSettings() {
675  $dbmysql5 = wfBoolToStr( $this->getVar( 'wgDBmysql5', true ) );
676  $prefix = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgDBprefix' ) );
678 
679  return "# MySQL specific settings
680 \$wgDBprefix = \"{$prefix}\";
681 
682 # MySQL table options to use during installation or update
683 \$wgDBTableOptions = \"{$tblOpts}\";
684 
685 # Experimental charset support for MySQL 5.0.
686 \$wgDBmysql5 = {$dbmysql5};";
687  }
688 }
MysqlInstaller\getTableOptions
getTableOptions()
Return any table options to be applied to all tables that don't override them.
Definition: MysqlInstaller.php:648
MysqlInstaller\submitSettingsForm
submitSettingsForm()
Definition: MysqlInstaller.php:438
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:45
MysqlInstaller\likeToRegex
likeToRegex( $wildcard)
Convert a wildcard (as used in LIKE) to a regex Slashes are escaped, slash terminators included.
Definition: MysqlInstaller.php:346
MysqlInstaller\getEngines
getEngines()
Get a list of storage engines that are available and supported.
Definition: MysqlInstaller.php:239
DatabaseInstaller\checkExtension
static checkExtension( $name)
Convenience function.
Definition: DatabaseInstaller.php:411
MysqlInstaller\getSettingsForm
getSettingsForm()
Definition: MysqlInstaller.php:358
captcha-old.count
count
Definition: captcha-old.py:225
MysqlInstaller\$supportedEngines
$supportedEngines
Definition: MysqlInstaller.php:52
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
MysqlInstaller\setupUser
setupUser()
Definition: MysqlInstaller.php:519
MysqlInstaller\userDefinitelyExists
userDefinitelyExists( $host, $user)
Try to see if the user account exists.
Definition: MysqlInstaller.php:631
DatabaseInstaller\getConnection
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
Definition: DatabaseInstaller.php:152
$status
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1049
MysqlInstaller\preInstall
preInstall()
Allow DB installers a chance to make last-minute changes before installation occurs.
Definition: MysqlInstaller.php:484
MysqlInstaller\getLocalSettings
getLocalSettings()
Get the DBMS-specific options for LocalSettings.php generation.
Definition: MysqlInstaller.php:674
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
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:246
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:63
DatabaseInstaller\getTextBox
getTextBox( $var, $label, $attribs=[], $helpData="")
Get a labelled text box to configure a local variable.
Definition: DatabaseInstaller.php:483
$s
$s
Definition: mergeMessageFileList.php:188
MysqlInstaller\openConnection
openConnection()
Definition: MysqlInstaller.php:147
MysqlInstaller\$minimumVersion
$minimumVersion
Definition: MysqlInstaller.php:54
$res
$res
Definition: database.txt:21
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
$wgDBpassword
$wgDBpassword
Database user's password.
Definition: DefaultSettings.php:1770
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
MysqlInstaller\getName
getName()
Definition: MysqlInstaller.php:67
MysqlInstaller\buildFullUserName
buildFullUserName( $name, $host)
Return a formal 'User'@'Host' username for use in queries.
Definition: MysqlInstaller.php:620
wfBoolToStr
wfBoolToStr( $value)
Convenience function converts boolean values into "true" or "false" (string) values.
Definition: GlobalFunctions.php:3179
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:309
MysqlInstaller\isCompiled
isCompiled()
Definition: MysqlInstaller.php:74
DatabaseInstaller\submitWebUserBox
submitWebUserBox()
Submit the form from getWebUserBox().
Definition: DatabaseInstaller.php:671
DatabaseInstaller\setupSchemaVars
setupSchemaVars()
Set appropriate schema variables in the current database connection.
Definition: DatabaseInstaller.php:312
MysqlInstaller\submitConnectForm
submitConnectForm()
Set variables based on the request array, assuming it was submitted via the form returned by getConne...
Definition: MysqlInstaller.php:98
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
DatabaseInstaller\getWebUserBox
getWebUserBox( $noCreateMsg=false)
Get a standard web-user fieldset.
Definition: DatabaseInstaller.php:644
Wikimedia\Rdbms\DBQueryError
Definition: DBQueryError.php:27
MysqlInstaller\$internalDefaults
$internalDefaults
Definition: MysqlInstaller.php:46
DatabaseInstaller\getRadioSet
getRadioSet( $params)
Get a set of labelled radio buttons.
Definition: DatabaseInstaller.php:562
MysqlInstaller\preUpgrade
preUpgrade()
Allow DB installers a chance to make checks before upgrade.
Definition: MysqlInstaller.php:165
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2122
DatabaseInstaller\getVar
getVar( $var, $default=null)
Get a variable, taking local defaults into account.
Definition: DatabaseInstaller.php:453
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:76
MysqlInstaller\getSchemaVars
getSchemaVars()
Get variables to substitute into tables.sql and the SQL patch files.
Definition: MysqlInstaller.php:665
DatabaseInstaller\submitInstallUserBox
submitInstallUserBox()
Submit a standard install user fieldset.
Definition: DatabaseInstaller.php:631
DatabaseInstaller
Base class for DBMS-specific installation helper classes.
Definition: DatabaseInstaller.php:33
MysqlInstaller\getCharsets
getCharsets()
Get a list of character sets that are available and supported.
Definition: MysqlInstaller.php:264
MysqlInstaller
Class for setting up the MediaWiki database using MySQL.
Definition: MysqlInstaller.php:34
MysqlInstaller\setupDatabase
setupDatabase()
Definition: MysqlInstaller.php:496
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
MysqlInstaller\$globalNames
$globalNames
Definition: MysqlInstaller.php:36
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
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:251
DatabaseInstaller\setVar
setVar( $name, $value)
Convenience alias for $this->parent->setVar()
Definition: DatabaseInstaller.php:470
DatabaseInstaller\getInstallUserBox
getInstallUserBox()
Get a standard install-user fieldset.
Definition: DatabaseInstaller.php:609
DatabaseInstaller\setVarsFromRequest
setVarsFromRequest( $varNames)
Convenience function to set variables based on form data.
Definition: DatabaseInstaller.php:576
Wikimedia\Rdbms\DBConnectionError
Definition: DBConnectionError.php:26
LocalSettingsGenerator\escapePhpString
static escapePhpString( $string)
Returns the escaped version of a string of php code.
Definition: LocalSettingsGenerator.php:114
MysqlInstaller\getConnectForm
getConnectForm()
Definition: MysqlInstaller.php:81
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 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
$wgDBuser
$wgDBuser
Database username.
Definition: DefaultSettings.php:1765
DatabaseInstaller\$db
Database $db
The database connection.
Definition: DatabaseInstaller.php:49
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
MysqlInstaller\$webUserPrivs
$webUserPrivs
Definition: MysqlInstaller.php:56
MysqlInstaller\canCreateAccounts
canCreateAccounts()
Return true if the install user can create accounts.
Definition: MysqlInstaller.php:273
$options
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
MysqlInstaller\escapeLikeInternal
escapeLikeInternal( $s, $escapeChar='`')
Definition: MysqlInstaller.php:228