MediaWiki  REL1_31
Installer.php
Go to the documentation of this file.
1 <?php
30 
46 abstract class Installer {
47 
54  const MINIMUM_PCRE_VERSION = '7.2';
55 
59  protected $settings;
60 
66  protected $compiledDBs;
67 
73  protected $dbInstallers = [];
74 
80  protected $minMemorySize = 50;
81 
87  protected $parserTitle;
88 
94  protected $parserOptions;
95 
105  protected static $dbTypes = [
106  'mysql',
107  'postgres',
108  'oracle',
109  'mssql',
110  'sqlite',
111  ];
112 
124  protected $envChecks = [
125  'envCheckDB',
126  'envCheckBrokenXML',
127  'envCheckPCRE',
128  'envCheckMemory',
129  'envCheckCache',
130  'envCheckModSecurity',
131  'envCheckDiff3',
132  'envCheckGraphics',
133  'envCheckGit',
134  'envCheckServer',
135  'envCheckPath',
136  'envCheckShellLocale',
137  'envCheckUploadsDirectory',
138  'envCheckLibicu',
139  'envCheckSuhosinMaxValueLength',
140  'envCheck64Bit',
141  ];
142 
148  protected $envPreps = [
149  'envPrepServer',
150  'envPrepPath',
151  ];
152 
160  protected $defaultVarNames = [
161  'wgSitename',
162  'wgPasswordSender',
163  'wgLanguageCode',
164  'wgRightsIcon',
165  'wgRightsText',
166  'wgRightsUrl',
167  'wgEnableEmail',
168  'wgEnableUserEmail',
169  'wgEnotifUserTalk',
170  'wgEnotifWatchlist',
171  'wgEmailAuthentication',
172  'wgDBname',
173  'wgDBtype',
174  'wgDiff3',
175  'wgImageMagickConvertCommand',
176  'wgGitBin',
177  'IP',
178  'wgScriptPath',
179  'wgMetaNamespace',
180  'wgDeletedDirectory',
181  'wgEnableUploads',
182  'wgShellLocale',
183  'wgSecretKey',
184  'wgUseInstantCommons',
185  'wgUpgradeKey',
186  'wgDefaultSkin',
187  'wgPingback',
188  ];
189 
197  protected $internalDefaults = [
198  '_UserLang' => 'en',
199  '_Environment' => false,
200  '_RaiseMemory' => false,
201  '_UpgradeDone' => false,
202  '_InstallDone' => false,
203  '_Caches' => [],
204  '_InstallPassword' => '',
205  '_SameAccount' => true,
206  '_CreateDBAccount' => false,
207  '_NamespaceType' => 'site-name',
208  '_AdminName' => '', // will be set later, when the user selects language
209  '_AdminPassword' => '',
210  '_AdminPasswordConfirm' => '',
211  '_AdminEmail' => '',
212  '_Subscribe' => false,
213  '_SkipOptional' => 'continue',
214  '_RightsProfile' => 'wiki',
215  '_LicenseCode' => 'none',
216  '_CCDone' => false,
217  '_Extensions' => [],
218  '_Skins' => [],
219  '_MemCachedServers' => '',
220  '_UpgradeKeySupplied' => false,
221  '_ExistingDBSettings' => false,
222 
223  // $wgLogo is probably wrong (T50084); set something that will work.
224  // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
225  'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
226  'wgAuthenticationTokenVersion' => 1,
227  ];
228 
234  private $installSteps = [];
235 
241  protected $extraInstallSteps = [];
242 
248  protected $objectCaches = [
249  'apc' => 'apc_fetch',
250  'apcu' => 'apcu_fetch',
251  'wincache' => 'wincache_ucache_get'
252  ];
253 
259  public $rightsProfiles = [
260  'wiki' => [],
261  'no-anon' => [
262  '*' => [ 'edit' => false ]
263  ],
264  'fishbowl' => [
265  '*' => [
266  'createaccount' => false,
267  'edit' => false,
268  ],
269  ],
270  'private' => [
271  '*' => [
272  'createaccount' => false,
273  'edit' => false,
274  'read' => false,
275  ],
276  ],
277  ];
278 
284  public $licenses = [
285  'cc-by' => [
286  'url' => 'https://creativecommons.org/licenses/by/4.0/',
287  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by.png',
288  ],
289  'cc-by-sa' => [
290  'url' => 'https://creativecommons.org/licenses/by-sa/4.0/',
291  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
292  ],
293  'cc-by-nc-sa' => [
294  'url' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
295  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
296  ],
297  'cc-0' => [
298  'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
299  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-0.png',
300  ],
301  'gfdl' => [
302  'url' => 'https://www.gnu.org/copyleft/fdl.html',
303  'icon' => '$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
304  ],
305  'none' => [
306  'url' => '',
307  'icon' => '',
308  'text' => ''
309  ],
310  'cc-choose' => [
311  // Details will be filled in by the selector.
312  'url' => '',
313  'icon' => '',
314  'text' => '',
315  ],
316  ];
317 
322  'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
323 
328  'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
329  'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
330  'sl', 'sr', 'sv', 'tr', 'uk'
331  ];
332 
340  abstract public function showMessage( $msg /*, ... */ );
341 
346  abstract public function showError( $msg /*, ... */ );
347 
352  abstract public function showStatusMessage( Status $status );
353 
364  public static function getInstallerConfig( Config $baseConfig ) {
365  $configOverrides = new HashConfig();
366 
367  // disable (problematic) object cache types explicitly, preserving all other (working) ones
368  // bug T113843
369  $emptyCache = [ 'class' => EmptyBagOStuff::class ];
370 
371  $objectCaches = [
372  CACHE_NONE => $emptyCache,
373  CACHE_DB => $emptyCache,
374  CACHE_ANYTHING => $emptyCache,
375  CACHE_MEMCACHED => $emptyCache,
376  ] + $baseConfig->get( 'ObjectCaches' );
377 
378  $configOverrides->set( 'ObjectCaches', $objectCaches );
379 
380  // Load the installer's i18n.
381  $messageDirs = $baseConfig->get( 'MessagesDirs' );
382  $messageDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
383 
384  $configOverrides->set( 'MessagesDirs', $messageDirs );
385 
386  $installerConfig = new MultiConfig( [ $configOverrides, $baseConfig ] );
387 
388  // make sure we use the installer config as the main config
389  $configRegistry = $baseConfig->get( 'ConfigRegistry' );
390  $configRegistry['main'] = function () use ( $installerConfig ) {
391  return $installerConfig;
392  };
393 
394  $configOverrides->set( 'ConfigRegistry', $configRegistry );
395 
396  return $installerConfig;
397  }
398 
402  public function __construct() {
404 
405  $defaultConfig = new GlobalVarConfig(); // all the stuff from DefaultSettings.php
406  $installerConfig = self::getInstallerConfig( $defaultConfig );
407 
408  // Reset all services and inject config overrides
409  MediaWikiServices::resetGlobalInstance( $installerConfig );
410 
411  // Don't attempt to load user language options (T126177)
412  // This will be overridden in the web installer with the user-specified language
413  RequestContext::getMain()->setLanguage( 'en' );
414 
415  // Disable the i18n cache
416  // TODO: manage LocalisationCache singleton in MediaWikiServices
417  Language::getLocalisationCache()->disableBackend();
418 
419  // Disable all global services, since we don't have any configuration yet!
420  MediaWikiServices::disableStorageBackend();
421 
422  $mwServices = MediaWikiServices::getInstance();
423  // Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
424  // SqlBagOStuff will then throw since we just disabled wfGetDB)
425  $wgObjectCaches = $mwServices->getMainConfig()->get( 'ObjectCaches' );
427 
428  // Disable interwiki lookup, to avoid database access during parses
429  $mwServices->redefineService( 'InterwikiLookup', function () {
430  return new NullInterwikiLookup();
431  } );
432 
433  // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
434  $wgUser = User::newFromId( 0 );
435  RequestContext::getMain()->setUser( $wgUser );
436 
438 
439  foreach ( $this->defaultVarNames as $var ) {
440  $this->settings[$var] = $GLOBALS[$var];
441  }
442 
443  $this->doEnvironmentPreps();
444 
445  $this->compiledDBs = [];
446  foreach ( self::getDBTypes() as $type ) {
447  $installer = $this->getDBInstaller( $type );
448 
449  if ( !$installer->isCompiled() ) {
450  continue;
451  }
452  $this->compiledDBs[] = $type;
453  }
454 
455  $this->parserTitle = Title::newFromText( 'Installer' );
456  $this->parserOptions = new ParserOptions( $wgUser ); // language will be wrong :(
457  // Don't try to access DB before user language is initialised
458  $this->setParserLanguage( Language::factory( 'en' ) );
459  }
460 
466  public static function getDBTypes() {
467  return self::$dbTypes;
468  }
469 
483  public function doEnvironmentChecks() {
484  // Php version has already been checked by entry scripts
485  // Show message here for information purposes
486  if ( wfIsHHVM() ) {
487  $this->showMessage( 'config-env-hhvm', HHVM_VERSION );
488  } else {
489  $this->showMessage( 'config-env-php', PHP_VERSION );
490  }
491 
492  $good = true;
493  // Must go here because an old version of PCRE can prevent other checks from completing
494  list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
495  if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
496  $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
497  $good = false;
498  } else {
499  foreach ( $this->envChecks as $check ) {
500  $status = $this->$check();
501  if ( $status === false ) {
502  $good = false;
503  }
504  }
505  }
506 
507  $this->setVar( '_Environment', $good );
508 
509  return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
510  }
511 
512  public function doEnvironmentPreps() {
513  foreach ( $this->envPreps as $prep ) {
514  $this->$prep();
515  }
516  }
517 
524  public function setVar( $name, $value ) {
525  $this->settings[$name] = $value;
526  }
527 
538  public function getVar( $name, $default = null ) {
539  if ( !isset( $this->settings[$name] ) ) {
540  return $default;
541  } else {
542  return $this->settings[$name];
543  }
544  }
545 
551  public function getCompiledDBs() {
552  return $this->compiledDBs;
553  }
554 
562  public static function getDBInstallerClass( $type ) {
563  return ucfirst( $type ) . 'Installer';
564  }
565 
573  public function getDBInstaller( $type = false ) {
574  if ( !$type ) {
575  $type = $this->getVar( 'wgDBtype' );
576  }
577 
578  $type = strtolower( $type );
579 
580  if ( !isset( $this->dbInstallers[$type] ) ) {
581  $class = self::getDBInstallerClass( $type );
582  $this->dbInstallers[$type] = new $class( $this );
583  }
584 
585  return $this->dbInstallers[$type];
586  }
587 
593  public static function getExistingLocalSettings() {
594  global $IP;
595 
596  // You might be wondering why this is here. Well if you don't do this
597  // then some poorly-formed extensions try to call their own classes
598  // after immediately registering them. We really need to get extension
599  // registration out of the global scope and into a real format.
600  // @see https://phabricator.wikimedia.org/T69440
602  $wgAutoloadClasses = [];
603 
604  // LocalSettings.php should not call functions, except wfLoadSkin/wfLoadExtensions
605  // Define the required globals here, to ensure, the functions can do it work correctly.
606  // phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables
608 
609  Wikimedia\suppressWarnings();
610  $_lsExists = file_exists( "$IP/LocalSettings.php" );
611  Wikimedia\restoreWarnings();
612 
613  if ( !$_lsExists ) {
614  return false;
615  }
616  unset( $_lsExists );
617 
618  require "$IP/includes/DefaultSettings.php";
619  require "$IP/LocalSettings.php";
620 
621  return get_defined_vars();
622  }
623 
633  public function getFakePassword( $realPassword ) {
634  return str_repeat( '*', strlen( $realPassword ) );
635  }
636 
644  public function setPassword( $name, $value ) {
645  if ( !preg_match( '/^\*+$/', $value ) ) {
646  $this->setVar( $name, $value );
647  }
648  }
649 
661  public static function maybeGetWebserverPrimaryGroup() {
662  if ( !function_exists( 'posix_getegid' ) || !function_exists( 'posix_getpwuid' ) ) {
663  # I don't know this, this isn't UNIX.
664  return null;
665  }
666 
667  # posix_getegid() *not* getmygid() because we want the group of the webserver,
668  # not whoever owns the current script.
669  $gid = posix_getegid();
670  $group = posix_getpwuid( $gid )['name'];
671 
672  return $group;
673  }
674 
691  public function parse( $text, $lineStart = false ) {
693 
694  try {
695  $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
696  $html = $out->getText( [
697  'enableSectionEditLinks' => false,
698  'unwrap' => true,
699  ] );
701  } catch ( MediaWiki\Services\ServiceDisabledException $e ) {
702  $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
703  }
704 
705  return $html;
706  }
707 
711  public function getParserOptions() {
712  return $this->parserOptions;
713  }
714 
715  public function disableLinkPopups() {
716  $this->parserOptions->setExternalLinkTarget( false );
717  }
718 
719  public function restoreLinkPopups() {
721  $this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
722  }
723 
732  public function populateSiteStats( DatabaseInstaller $installer ) {
733  $status = $installer->getConnection();
734  if ( !$status->isOK() ) {
735  return $status;
736  }
737  $status->value->insert(
738  'site_stats',
739  [
740  'ss_row_id' => 1,
741  'ss_total_edits' => 0,
742  'ss_good_articles' => 0,
743  'ss_total_pages' => 0,
744  'ss_users' => 0,
745  'ss_active_users' => 0,
746  'ss_images' => 0
747  ],
748  __METHOD__, 'IGNORE'
749  );
750 
751  return Status::newGood();
752  }
753 
758  protected function envCheckDB() {
759  global $wgLang;
760 
761  $allNames = [];
762 
763  // Messages: config-type-mysql, config-type-postgres, config-type-oracle,
764  // config-type-sqlite
765  foreach ( self::getDBTypes() as $name ) {
766  $allNames[] = wfMessage( "config-type-$name" )->text();
767  }
768 
769  $databases = $this->getCompiledDBs();
770 
771  $databases = array_flip( $databases );
772  foreach ( array_keys( $databases ) as $db ) {
773  $installer = $this->getDBInstaller( $db );
774  $status = $installer->checkPrerequisites();
775  if ( !$status->isGood() ) {
776  $this->showStatusMessage( $status );
777  }
778  if ( !$status->isOK() ) {
779  unset( $databases[$db] );
780  }
781  }
782  $databases = array_flip( $databases );
783  if ( !$databases ) {
784  $this->showError( 'config-no-db', $wgLang->commaList( $allNames ), count( $allNames ) );
785 
786  // @todo FIXME: This only works for the web installer!
787  return false;
788  }
789 
790  return true;
791  }
792 
797  protected function envCheckBrokenXML() {
798  $test = new PhpXmlBugTester();
799  if ( !$test->ok ) {
800  $this->showError( 'config-brokenlibxml' );
801 
802  return false;
803  }
804 
805  return true;
806  }
807 
816  protected function envCheckPCRE() {
817  Wikimedia\suppressWarnings();
818  $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
819  // Need to check for \p support too, as PCRE can be compiled
820  // with utf8 support, but not unicode property support.
821  // check that \p{Zs} (space separators) matches
822  // U+3000 (Ideographic space)
823  $regexprop = preg_replace( '/\p{Zs}/u', '', "-\xE3\x80\x80-" );
824  Wikimedia\restoreWarnings();
825  if ( $regexd != '--' || $regexprop != '--' ) {
826  $this->showError( 'config-pcre-no-utf8' );
827 
828  return false;
829  }
830 
831  return true;
832  }
833 
838  protected function envCheckMemory() {
839  $limit = ini_get( 'memory_limit' );
840 
841  if ( !$limit || $limit == -1 ) {
842  return true;
843  }
844 
845  $n = wfShorthandToInteger( $limit );
846 
847  if ( $n < $this->minMemorySize * 1024 * 1024 ) {
848  $newLimit = "{$this->minMemorySize}M";
849 
850  if ( ini_set( "memory_limit", $newLimit ) === false ) {
851  $this->showMessage( 'config-memory-bad', $limit );
852  } else {
853  $this->showMessage( 'config-memory-raised', $limit, $newLimit );
854  $this->setVar( '_RaiseMemory', true );
855  }
856  }
857 
858  return true;
859  }
860 
864  protected function envCheckCache() {
865  $caches = [];
866  foreach ( $this->objectCaches as $name => $function ) {
867  if ( function_exists( $function ) ) {
868  $caches[$name] = true;
869  }
870  }
871 
872  if ( !$caches ) {
873  $key = 'config-no-cache-apcu';
874  $this->showMessage( $key );
875  }
876 
877  $this->setVar( '_Caches', $caches );
878  }
879 
884  protected function envCheckModSecurity() {
885  if ( self::apacheModulePresent( 'mod_security' )
886  || self::apacheModulePresent( 'mod_security2' ) ) {
887  $this->showMessage( 'config-mod-security' );
888  }
889 
890  return true;
891  }
892 
897  protected function envCheckDiff3() {
898  $names = [ "gdiff3", "diff3" ];
899  if ( wfIsWindows() ) {
900  $names[] = 'diff3.exe';
901  }
902  $versionInfo = [ '--version', 'GNU diffutils' ];
903 
904  $diff3 = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
905 
906  if ( $diff3 ) {
907  $this->setVar( 'wgDiff3', $diff3 );
908  } else {
909  $this->setVar( 'wgDiff3', false );
910  $this->showMessage( 'config-diff3-bad' );
911  }
912 
913  return true;
914  }
915 
920  protected function envCheckGraphics() {
921  $names = wfIsWindows() ? 'convert.exe' : 'convert';
922  $versionInfo = [ '-version', 'ImageMagick' ];
923  $convert = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
924 
925  $this->setVar( 'wgImageMagickConvertCommand', '' );
926  if ( $convert ) {
927  $this->setVar( 'wgImageMagickConvertCommand', $convert );
928  $this->showMessage( 'config-imagemagick', $convert );
929 
930  return true;
931  } elseif ( function_exists( 'imagejpeg' ) ) {
932  $this->showMessage( 'config-gd' );
933  } else {
934  $this->showMessage( 'config-no-scaling' );
935  }
936 
937  return true;
938  }
939 
946  protected function envCheckGit() {
947  $names = wfIsWindows() ? 'git.exe' : 'git';
948  $versionInfo = [ '--version', 'git version' ];
949 
950  $git = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
951 
952  if ( $git ) {
953  $this->setVar( 'wgGitBin', $git );
954  $this->showMessage( 'config-git', $git );
955  } else {
956  $this->setVar( 'wgGitBin', false );
957  $this->showMessage( 'config-git-bad' );
958  }
959 
960  return true;
961  }
962 
968  protected function envCheckServer() {
969  $server = $this->envGetDefaultServer();
970  if ( $server !== null ) {
971  $this->showMessage( 'config-using-server', $server );
972  }
973  return true;
974  }
975 
981  protected function envCheckPath() {
982  $this->showMessage(
983  'config-using-uri',
984  $this->getVar( 'wgServer' ),
985  $this->getVar( 'wgScriptPath' )
986  );
987  return true;
988  }
989 
994  protected function envCheckShellLocale() {
995  $os = php_uname( 's' );
996  $supported = [ 'Linux', 'SunOS', 'HP-UX', 'Darwin' ]; # Tested these
997 
998  if ( !in_array( $os, $supported ) ) {
999  return true;
1000  }
1001 
1002  if ( Shell::isDisabled() ) {
1003  return true;
1004  }
1005 
1006  # Get a list of available locales.
1007  $result = Shell::command( '/usr/bin/locale', '-a' )
1008  ->execute();
1009 
1010  if ( $result->getExitCode() != 0 ) {
1011  return true;
1012  }
1013 
1014  $lines = $result->getStdout();
1015  $lines = array_map( 'trim', explode( "\n", $lines ) );
1016  $candidatesByLocale = [];
1017  $candidatesByLang = [];
1018  foreach ( $lines as $line ) {
1019  if ( $line === '' ) {
1020  continue;
1021  }
1022 
1023  if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
1024  continue;
1025  }
1026 
1027  list( , $lang, , , ) = $m;
1028 
1029  $candidatesByLocale[$m[0]] = $m;
1030  $candidatesByLang[$lang][] = $m;
1031  }
1032 
1033  # Try the current value of LANG.
1034  if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
1035  $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
1036 
1037  return true;
1038  }
1039 
1040  # Try the most common ones.
1041  $commonLocales = [ 'C.UTF-8', 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ];
1042  foreach ( $commonLocales as $commonLocale ) {
1043  if ( isset( $candidatesByLocale[$commonLocale] ) ) {
1044  $this->setVar( 'wgShellLocale', $commonLocale );
1045 
1046  return true;
1047  }
1048  }
1049 
1050  # Is there an available locale in the Wiki's language?
1051  $wikiLang = $this->getVar( 'wgLanguageCode' );
1052 
1053  if ( isset( $candidatesByLang[$wikiLang] ) ) {
1054  $m = reset( $candidatesByLang[$wikiLang] );
1055  $this->setVar( 'wgShellLocale', $m[0] );
1056 
1057  return true;
1058  }
1059 
1060  # Are there any at all?
1061  if ( count( $candidatesByLocale ) ) {
1062  $m = reset( $candidatesByLocale );
1063  $this->setVar( 'wgShellLocale', $m[0] );
1064 
1065  return true;
1066  }
1067 
1068  # Give up.
1069  return true;
1070  }
1071 
1076  protected function envCheckUploadsDirectory() {
1077  global $IP;
1078 
1079  $dir = $IP . '/images/';
1080  $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
1081  $safe = !$this->dirIsExecutable( $dir, $url );
1082 
1083  if ( !$safe ) {
1084  $this->showMessage( 'config-uploads-not-safe', $dir );
1085  }
1086 
1087  return true;
1088  }
1089 
1095  protected function envCheckSuhosinMaxValueLength() {
1096  $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
1097  if ( $maxValueLength > 0 && $maxValueLength < 1024 ) {
1098  // Only warn if the value is below the sane 1024
1099  $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
1100  }
1101 
1102  return true;
1103  }
1104 
1111  protected function envCheck64Bit() {
1112  if ( PHP_INT_SIZE == 4 ) {
1113  $this->showMessage( 'config-using-32bit' );
1114  }
1115 
1116  return true;
1117  }
1118 
1124  protected function unicodeChar( $c ) {
1125  $c = hexdec( $c );
1126  if ( $c <= 0x7F ) {
1127  return chr( $c );
1128  } elseif ( $c <= 0x7FF ) {
1129  return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
1130  } elseif ( $c <= 0xFFFF ) {
1131  return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F ) .
1132  chr( 0x80 | $c & 0x3F );
1133  } elseif ( $c <= 0x10FFFF ) {
1134  return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F ) .
1135  chr( 0x80 | $c >> 6 & 0x3F ) .
1136  chr( 0x80 | $c & 0x3F );
1137  } else {
1138  return false;
1139  }
1140  }
1141 
1145  protected function envCheckLibicu() {
1153  $not_normal_c = $this->unicodeChar( "FA6C" );
1154  $normal_c = $this->unicodeChar( "242EE" );
1155 
1156  $useNormalizer = 'php';
1157  $needsUpdate = false;
1158 
1159  if ( function_exists( 'normalizer_normalize' ) ) {
1160  $useNormalizer = 'intl';
1161  $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
1162  if ( $intl !== $normal_c ) {
1163  $needsUpdate = true;
1164  }
1165  }
1166 
1167  // Uses messages 'config-unicode-using-php' and 'config-unicode-using-intl'
1168  if ( $useNormalizer === 'php' ) {
1169  $this->showMessage( 'config-unicode-pure-php-warning' );
1170  } else {
1171  $this->showMessage( 'config-unicode-using-' . $useNormalizer );
1172  if ( $needsUpdate ) {
1173  $this->showMessage( 'config-unicode-update-warning' );
1174  }
1175  }
1176  }
1177 
1181  protected function envPrepServer() {
1182  $server = $this->envGetDefaultServer();
1183  if ( $server !== null ) {
1184  $this->setVar( 'wgServer', $server );
1185  }
1186  }
1187 
1192  abstract protected function envGetDefaultServer();
1193 
1197  protected function envPrepPath() {
1198  global $IP;
1199  $IP = dirname( dirname( __DIR__ ) );
1200  $this->setVar( 'IP', $IP );
1201  }
1202 
1211  public function dirIsExecutable( $dir, $url ) {
1212  $scriptTypes = [
1213  'php' => [
1214  "<?php echo 'ex' . 'ec';",
1215  "#!/var/env php\n<?php echo 'ex' . 'ec';",
1216  ],
1217  ];
1218 
1219  // it would be good to check other popular languages here, but it'll be slow.
1220 
1221  Wikimedia\suppressWarnings();
1222 
1223  foreach ( $scriptTypes as $ext => $contents ) {
1224  foreach ( $contents as $source ) {
1225  $file = 'exectest.' . $ext;
1226 
1227  if ( !file_put_contents( $dir . $file, $source ) ) {
1228  break;
1229  }
1230 
1231  try {
1232  $text = Http::get( $url . $file, [ 'timeout' => 3 ], __METHOD__ );
1233  } catch ( Exception $e ) {
1234  // Http::get throws with allow_url_fopen = false and no curl extension.
1235  $text = null;
1236  }
1237  unlink( $dir . $file );
1238 
1239  if ( $text == 'exec' ) {
1240  Wikimedia\restoreWarnings();
1241 
1242  return $ext;
1243  }
1244  }
1245  }
1246 
1247  Wikimedia\restoreWarnings();
1248 
1249  return false;
1250  }
1251 
1258  public static function apacheModulePresent( $moduleName ) {
1259  if ( function_exists( 'apache_get_modules' ) && in_array( $moduleName, apache_get_modules() ) ) {
1260  return true;
1261  }
1262  // try it the hard way
1263  ob_start();
1264  phpinfo( INFO_MODULES );
1265  $info = ob_get_clean();
1266 
1267  return strpos( $info, $moduleName ) !== false;
1268  }
1269 
1275  public function setParserLanguage( $lang ) {
1276  $this->parserOptions->setTargetLanguage( $lang );
1277  $this->parserOptions->setUserLang( $lang );
1278  }
1279 
1285  protected function getDocUrl( $page ) {
1286  return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1287  }
1288 
1298  public function findExtensions( $directory = 'extensions' ) {
1299  if ( $this->getVar( 'IP' ) === null ) {
1300  return [];
1301  }
1302 
1303  $extDir = $this->getVar( 'IP' ) . '/' . $directory;
1304  if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
1305  return [];
1306  }
1307 
1308  // extensions -> extension.json, skins -> skin.json
1309  $jsonFile = substr( $directory, 0, strlen( $directory ) - 1 ) . '.json';
1310 
1311  $dh = opendir( $extDir );
1312  $exts = [];
1313  while ( ( $file = readdir( $dh ) ) !== false ) {
1314  if ( !is_dir( "$extDir/$file" ) ) {
1315  continue;
1316  }
1317  $fullJsonFile = "$extDir/$file/$jsonFile";
1318  $isJson = file_exists( $fullJsonFile );
1319  $isPhp = false;
1320  if ( !$isJson ) {
1321  // Only fallback to PHP file if JSON doesn't exist
1322  $fullPhpFile = "$extDir/$file/$file.php";
1323  $isPhp = file_exists( $fullPhpFile );
1324  }
1325  if ( $isJson || $isPhp ) {
1326  // Extension exists. Now see if there are screenshots
1327  $exts[$file] = [];
1328  if ( is_dir( "$extDir/$file/screenshots" ) ) {
1329  $paths = glob( "$extDir/$file/screenshots/*.png" );
1330  foreach ( $paths as $path ) {
1331  $exts[$file]['screenshots'][] = str_replace( $extDir, "../$directory", $path );
1332  }
1333 
1334  }
1335  }
1336  if ( $isJson ) {
1337  $info = $this->readExtension( $fullJsonFile );
1338  if ( $info === false ) {
1339  continue;
1340  }
1341  $exts[$file] += $info;
1342  }
1343  }
1344  closedir( $dh );
1345  uksort( $exts, 'strnatcasecmp' );
1346 
1347  return $exts;
1348  }
1349 
1357  private function readExtension( $fullJsonFile, $extDeps = [], $skinDeps = [] ) {
1358  $load = [
1359  $fullJsonFile => 1
1360  ];
1361  if ( $extDeps ) {
1362  $extDir = $this->getVar( 'IP' ) . '/extensions';
1363  foreach ( $extDeps as $dep ) {
1364  $fname = "$extDir/$dep/extension.json";
1365  if ( !file_exists( $fname ) ) {
1366  return false;
1367  }
1368  $load[$fname] = 1;
1369  }
1370  }
1371  if ( $skinDeps ) {
1372  $skinDir = $this->getVar( 'IP' ) . '/skins';
1373  foreach ( $skinDeps as $dep ) {
1374  $fname = "$skinDir/$dep/skin.json";
1375  if ( !file_exists( $fname ) ) {
1376  return false;
1377  }
1378  $load[$fname] = 1;
1379  }
1380  }
1381  $registry = new ExtensionRegistry();
1382  try {
1383  $info = $registry->readFromQueue( $load );
1384  } catch ( ExtensionDependencyError $e ) {
1385  if ( $e->incompatibleCore || $e->incompatibleSkins
1386  || $e->incompatibleExtensions
1387  ) {
1388  // If something is incompatible with a dependency, we have no real
1389  // option besides skipping it
1390  return false;
1391  } elseif ( $e->missingExtensions || $e->missingSkins ) {
1392  // There's an extension missing in the dependency tree,
1393  // so add those to the dependency list and try again
1394  return $this->readExtension(
1395  $fullJsonFile,
1396  array_merge( $extDeps, $e->missingExtensions ),
1397  array_merge( $skinDeps, $e->missingSkins )
1398  );
1399  }
1400  // Some other kind of dependency error?
1401  return false;
1402  }
1403  $ret = [];
1404  // The order of credits will be the order of $load,
1405  // so the first extension is the one we want to load,
1406  // everything else is a dependency
1407  $i = 0;
1408  foreach ( $info['credits'] as $name => $credit ) {
1409  $i++;
1410  if ( $i == 1 ) {
1411  // Extension we want to load
1412  continue;
1413  }
1414  $type = basename( $credit['path'] ) === 'skin.json' ? 'skins' : 'extensions';
1415  $ret['requires'][$type][] = $credit['name'];
1416  }
1417  $credits = array_values( $info['credits'] )[0];
1418  if ( isset( $credits['url'] ) ) {
1419  $ret['url'] = $credits['url'];
1420  }
1421  $ret['type'] = $credits['type'];
1422 
1423  return $ret;
1424  }
1425 
1434  public function getDefaultSkin( array $skinNames ) {
1435  $defaultSkin = $GLOBALS['wgDefaultSkin'];
1436  if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) {
1437  return $defaultSkin;
1438  } else {
1439  return $skinNames[0];
1440  }
1441  }
1442 
1448  protected function includeExtensions() {
1449  global $IP;
1450  $exts = $this->getVar( '_Extensions' );
1451  $IP = $this->getVar( 'IP' );
1452 
1453  // Marker for DatabaseUpdater::loadExtensions so we don't
1454  // double load extensions
1455  define( 'MW_EXTENSIONS_LOADED', true );
1456 
1466  $wgAutoloadClasses = [];
1467  $queue = [];
1468 
1469  require "$IP/includes/DefaultSettings.php";
1470 
1471  foreach ( $exts as $e ) {
1472  if ( file_exists( "$IP/extensions/$e/extension.json" ) ) {
1473  $queue["$IP/extensions/$e/extension.json"] = 1;
1474  } else {
1475  require_once "$IP/extensions/$e/$e.php";
1476  }
1477  }
1478 
1479  $registry = new ExtensionRegistry();
1480  $data = $registry->readFromQueue( $queue );
1481  $wgAutoloadClasses += $data['autoload'];
1482 
1483  $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
1485  $wgHooks['LoadExtensionSchemaUpdates'] : [];
1486 
1487  if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
1488  $hooksWeWant = array_merge_recursive(
1489  $hooksWeWant,
1490  $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']
1491  );
1492  }
1493  // Unset everyone else's hooks. Lord knows what someone might be doing
1494  // in ParserFirstCallInit (see T29171)
1495  $GLOBALS['wgHooks'] = [ 'LoadExtensionSchemaUpdates' => $hooksWeWant ];
1496 
1497  return Status::newGood();
1498  }
1499 
1512  protected function getInstallSteps( DatabaseInstaller $installer ) {
1513  $coreInstallSteps = [
1514  [ 'name' => 'database', 'callback' => [ $installer, 'setupDatabase' ] ],
1515  [ 'name' => 'tables', 'callback' => [ $installer, 'createTables' ] ],
1516  [ 'name' => 'interwiki', 'callback' => [ $installer, 'populateInterwikiTable' ] ],
1517  [ 'name' => 'stats', 'callback' => [ $this, 'populateSiteStats' ] ],
1518  [ 'name' => 'keys', 'callback' => [ $this, 'generateKeys' ] ],
1519  [ 'name' => 'updates', 'callback' => [ $installer, 'insertUpdateKeys' ] ],
1520  [ 'name' => 'sysop', 'callback' => [ $this, 'createSysop' ] ],
1521  [ 'name' => 'mainpage', 'callback' => [ $this, 'createMainpage' ] ],
1522  ];
1523 
1524  // Build the array of install steps starting from the core install list,
1525  // then adding any callbacks that wanted to attach after a given step
1526  foreach ( $coreInstallSteps as $step ) {
1527  $this->installSteps[] = $step;
1528  if ( isset( $this->extraInstallSteps[$step['name']] ) ) {
1529  $this->installSteps = array_merge(
1530  $this->installSteps,
1531  $this->extraInstallSteps[$step['name']]
1532  );
1533  }
1534  }
1535 
1536  // Prepend any steps that want to be at the beginning
1537  if ( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
1538  $this->installSteps = array_merge(
1539  $this->extraInstallSteps['BEGINNING'],
1540  $this->installSteps
1541  );
1542  }
1543 
1544  // Extensions should always go first, chance to tie into hooks and such
1545  if ( count( $this->getVar( '_Extensions' ) ) ) {
1546  array_unshift( $this->installSteps,
1547  [ 'name' => 'extensions', 'callback' => [ $this, 'includeExtensions' ] ]
1548  );
1549  $this->installSteps[] = [
1550  'name' => 'extension-tables',
1551  'callback' => [ $installer, 'createExtensionTables' ]
1552  ];
1553  }
1554 
1555  return $this->installSteps;
1556  }
1557 
1566  public function performInstallation( $startCB, $endCB ) {
1567  $installResults = [];
1568  $installer = $this->getDBInstaller();
1569  $installer->preInstall();
1570  $steps = $this->getInstallSteps( $installer );
1571  foreach ( $steps as $stepObj ) {
1572  $name = $stepObj['name'];
1573  call_user_func_array( $startCB, [ $name ] );
1574 
1575  // Perform the callback step
1576  $status = call_user_func( $stepObj['callback'], $installer );
1577 
1578  // Output and save the results
1579  call_user_func( $endCB, $name, $status );
1580  $installResults[$name] = $status;
1581 
1582  // If we've hit some sort of fatal, we need to bail.
1583  // Callback already had a chance to do output above.
1584  if ( !$status->isOk() ) {
1585  break;
1586  }
1587  }
1588  if ( $status->isOk() ) {
1589  $this->showMessage(
1590  'config-install-success',
1591  $this->getVar( 'wgServer' ),
1592  $this->getVar( 'wgScriptPath' )
1593  );
1594  $this->setVar( '_InstallDone', true );
1595  }
1596 
1597  return $installResults;
1598  }
1599 
1605  public function generateKeys() {
1606  $keys = [ 'wgSecretKey' => 64 ];
1607  if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
1608  $keys['wgUpgradeKey'] = 16;
1609  }
1610 
1611  return $this->doGenerateKeys( $keys );
1612  }
1613 
1621  protected function doGenerateKeys( $keys ) {
1623 
1624  $strong = true;
1625  foreach ( $keys as $name => $length ) {
1626  $secretKey = MWCryptRand::generateHex( $length, true );
1627  if ( !MWCryptRand::wasStrong() ) {
1628  $strong = false;
1629  }
1630 
1631  $this->setVar( $name, $secretKey );
1632  }
1633 
1634  if ( !$strong ) {
1635  $names = array_keys( $keys );
1636  $names = preg_replace( '/^(.*)$/', '\$$1', $names );
1637  global $wgLang;
1638  $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
1639  }
1640 
1641  return $status;
1642  }
1643 
1649  protected function createSysop() {
1650  $name = $this->getVar( '_AdminName' );
1652 
1653  if ( !$user ) {
1654  // We should've validated this earlier anyway!
1655  return Status::newFatal( 'config-admin-error-user', $name );
1656  }
1657 
1658  if ( $user->idForName() == 0 ) {
1659  $user->addToDatabase();
1660 
1661  try {
1662  $user->setPassword( $this->getVar( '_AdminPassword' ) );
1663  } catch ( PasswordError $pwe ) {
1664  return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
1665  }
1666 
1667  $user->addGroup( 'sysop' );
1668  $user->addGroup( 'bureaucrat' );
1669  if ( $this->getVar( '_AdminEmail' ) ) {
1670  $user->setEmail( $this->getVar( '_AdminEmail' ) );
1671  }
1672  $user->saveSettings();
1673 
1674  // Update user count
1675  $ssUpdate = SiteStatsUpdate::factory( [ 'users' => 1 ] );
1676  $ssUpdate->doUpdate();
1677  }
1679 
1680  if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
1682  }
1683 
1684  return $status;
1685  }
1686 
1691  $params = [
1692  'email' => $this->getVar( '_AdminEmail' ),
1693  'language' => 'en',
1694  'digest' => 0
1695  ];
1696 
1697  // Mailman doesn't support as many languages as we do, so check to make
1698  // sure their selected language is available
1699  $myLang = $this->getVar( '_UserLang' );
1700  if ( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
1701  $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
1702  $params['language'] = $myLang;
1703  }
1704 
1706  $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
1707  [ 'method' => 'POST', 'postData' => $params ], __METHOD__ )->execute();
1708  if ( !$res->isOK() ) {
1709  $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
1710  }
1711  } else {
1712  $s->warning( 'config-install-subscribe-notpossible' );
1713  }
1714  }
1715 
1722  protected function createMainpage( DatabaseInstaller $installer ) {
1725  if ( $title->exists() ) {
1726  $status->warning( 'config-install-mainpage-exists' );
1727  return $status;
1728  }
1729  try {
1730  $page = WikiPage::factory( $title );
1731  $content = new WikitextContent(
1732  wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
1733  wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
1734  );
1735 
1736  $status = $page->doEditContent( $content,
1737  '',
1738  EDIT_NEW,
1739  false,
1740  User::newFromName( 'MediaWiki default' )
1741  );
1742  } catch ( Exception $e ) {
1743  // using raw, because $wgShowExceptionDetails can not be set yet
1744  $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
1745  }
1746 
1747  return $status;
1748  }
1749 
1753  public static function overrideConfig() {
1754  // Use PHP's built-in session handling, since MediaWiki's
1755  // SessionHandler can't work before we have an object cache set up.
1756  define( 'MW_NO_SESSION_HANDLER', 1 );
1757 
1758  // Don't access the database
1759  $GLOBALS['wgUseDatabaseMessages'] = false;
1760  // Don't cache langconv tables
1761  $GLOBALS['wgLanguageConverterCacheType'] = CACHE_NONE;
1762  // Debug-friendly
1763  $GLOBALS['wgShowExceptionDetails'] = true;
1764  // Don't break forms
1765  $GLOBALS['wgExternalLinkTarget'] = '_blank';
1766 
1767  // Extended debugging
1768  $GLOBALS['wgShowSQLErrors'] = true;
1769  $GLOBALS['wgShowDBErrorBacktrace'] = true;
1770 
1771  // Allow multiple ob_flush() calls
1772  $GLOBALS['wgDisableOutputCompression'] = true;
1773 
1774  // Use a sensible cookie prefix (not my_wiki)
1775  $GLOBALS['wgCookiePrefix'] = 'mw_installer';
1776 
1777  // Some of the environment checks make shell requests, remove limits
1778  $GLOBALS['wgMaxShellMemory'] = 0;
1779 
1780  // Override the default CookieSessionProvider with a dummy
1781  // implementation that won't stomp on PHP's cookies.
1782  $GLOBALS['wgSessionProviders'] = [
1783  [
1785  'args' => [ [
1786  'priority' => 1,
1787  ] ]
1788  ]
1789  ];
1790 
1791  // Don't try to use any object cache for SessionManager either.
1792  $GLOBALS['wgSessionCacheType'] = CACHE_NONE;
1793  }
1794 
1802  public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
1803  $this->extraInstallSteps[$findStep][] = $callback;
1804  }
1805 
1810  protected function disableTimeLimit() {
1811  Wikimedia\suppressWarnings();
1812  set_time_limit( 0 );
1813  Wikimedia\restoreWarnings();
1814  }
1815 }
Installer\envCheckBrokenXML
envCheckBrokenXML()
Some versions of libxml+PHP break < and > encoding horribly.
Definition: Installer.php:797
$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:247
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:40
MediaWiki\Shell\Shell
Executes shell commands.
Definition: Shell.php:44
Installer\__construct
__construct()
Constructor, always call this from child classes.
Definition: Installer.php:402
$wgUser
$wgUser
Definition: Setup.php:902
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:614
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:273
MWCryptRand\wasStrong
static wasStrong()
Return a boolean indicating whether or not the source used for cryptographic random bytes generation ...
Definition: MWCryptRand.php:44
Installer\createMainpage
createMainpage(DatabaseInstaller $installer)
Insert Main Page with default content.
Definition: Installer.php:1722
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
Installer\showMessage
showMessage( $msg)
UI interface for displaying a short message The parameters are like parameters to wfMessage().
$wgParser
$wgParser
Definition: Setup.php:917
$html
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 & $html
Definition: hooks.txt:2013
Installer\parse
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
Definition: Installer.php:691
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
ExtensionDependencyError
Copyright (C) 2018 Kunal Mehta legoktm@member.fsf.org
Definition: ExtensionDependencyError.php:24
MultiConfig
Provides a fallback sequence for Config objects.
Definition: MultiConfig.php:28
array
the array() calling protocol came about after MediaWiki 1.4rc1.
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
HashConfig
A Config instance which stores all settings as a member variable.
Definition: HashConfig.php:28
$wgMemc
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest to get request data $wgMemc
Definition: globals.txt:66
Installer\showStatusMessage
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
Installer\dirIsExecutable
dirIsExecutable( $dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
Definition: Installer.php:1211
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:18
CACHE_NONE
const CACHE_NONE
Definition: Defines.php:112
Installer\envCheckLibicu
envCheckLibicu()
Check the libicu version.
Definition: Installer.php:1145
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:586
ExtensionRegistry
ExtensionRegistry class.
Definition: ExtensionRegistry.php:14
CACHE_MEMCACHED
const CACHE_MEMCACHED
Definition: Defines.php:114
Installer\populateSiteStats
populateSiteStats(DatabaseInstaller $installer)
Install step which adds a row to the site_stats table with appropriate initial values.
Definition: Installer.php:732
$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:2005
Installer\$extraInstallSteps
array $extraInstallSteps
Extra steps for installation, for things like DatabaseInstallers to modify.
Definition: Installer.php:241
DatabaseInstaller\getConnection
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
Definition: DatabaseInstaller.php:179
Installer\$rightsProfiles
array $rightsProfiles
User rights profiles.
Definition: Installer.php:259
Installer\envCheckShellLocale
envCheckShellLocale()
Environment check for preferred locale in shell.
Definition: Installer.php:994
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:864
Installer\envCheckUploadsDirectory
envCheckUploadsDirectory()
Environment check for the permissions of the uploads directory.
Definition: Installer.php:1076
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:68
Installer\$settings
array $settings
Definition: Installer.php:59
Installer\envPrepServer
envPrepServer()
Environment prep for the server hostname.
Definition: Installer.php:1181
$params
$params
Definition: styleTest.css.php:40
Installer\performInstallation
performInstallation( $startCB, $endCB)
Actually perform the installation.
Definition: Installer.php:1566
Installer\$mediaWikiAnnounceLanguages
$mediaWikiAnnounceLanguages
Supported language codes for Mailman.
Definition: Installer.php:327
PasswordError
Show an error when any operation involving passwords fails to run.
Definition: PasswordError.php:26
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:591
MediaWiki\Interwiki\NullInterwikiLookup
An interwiki lookup that has no data, intended for use in the installer.
Definition: NullInterwikiLookup.php:29
$s
$s
Definition: mergeMessageFileList.php:187
MWCryptRand\generateHex
static generateHex( $chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
Definition: MWCryptRand.php:76
$res
$res
Definition: database.txt:21
Installer\$dbInstallers
array $dbInstallers
Cached DB installer instances, access using getDBInstaller().
Definition: Installer.php:73
Installer\setParserLanguage
setParserLanguage( $lang)
ParserOptions are constructed before we determined the language, so fix it.
Definition: Installer.php:1275
Installer\addInstallStep
addInstallStep( $callback, $findStep='BEGINNING')
Add an installation step following the given step.
Definition: Installer.php:1802
Installer\$internalDefaults
array $internalDefaults
Variables that are stored alongside globals, and are used for any configuration of the installation p...
Definition: Installer.php:197
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1993
Installer\setPassword
setPassword( $name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
Definition: Installer.php:644
Installer\envGetDefaultServer
envGetDefaultServer()
Helper function to be called from envPrepServer()
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:37
Installer\setVar
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:524
Installer\$parserTitle
Title $parserTitle
Cached Title, used by parse().
Definition: Installer.php:87
Installer\$objectCaches
array $objectCaches
Known object cache types and the functions used to test for their existence.
Definition: Installer.php:248
Installer\$minMemorySize
int $minMemorySize
Minimum memory size in MB.
Definition: Installer.php:80
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:40
Installer\overrideConfig
static overrideConfig()
Override the necessary bits of the config to run an installation.
Definition: Installer.php:1753
Installer\createSysop
createSysop()
Create the first user account, grant it sysop and bureaucrat rights.
Definition: Installer.php:1649
Installer\getFakePassword
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
Definition: Installer.php:633
Config
Interface for configuration instances.
Definition: Config.php:28
Installer\envCheckSuhosinMaxValueLength
envCheckSuhosinMaxValueLength()
Checks if suhosin.get.max_value_length is set, and if so generate a warning because it decreases Reso...
Definition: Installer.php:1095
Language\getLocalisationCache
static getLocalisationCache()
Get the LocalisationCache instance.
Definition: Language.php:406
Installer\showError
showError( $msg)
Same as showMessage(), but for displaying errors.
Installer\envPrepPath
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
Definition: Installer.php:1197
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:115
Installer\envCheckDiff3
envCheckDiff3()
Search for GNU diff3.
Definition: Installer.php:897
Config\get
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
Installer\generateKeys
generateKeys()
Generate $wgSecretKey.
Definition: Installer.php:1605
Installer\envCheckMemory
envCheckMemory()
Environment check for available memory.
Definition: Installer.php:838
MediaWiki
A helper class for throttling authentication attempts.
$wgObjectCaches
$wgObjectCaches
Advanced object cache configuration.
Definition: DefaultSettings.php:2319
Installer\getCompiledDBs
getCompiledDBs()
Get a list of DBs supported by current PHP setup.
Definition: Installer.php:551
ObjectCache\getInstance
static getInstance( $id)
Get a cached instance of the specified type of cache object.
Definition: ObjectCache.php:92
$queue
$queue
Definition: mergeMessageFileList.php:160
Installer\envCheckCache
envCheckCache()
Environment check for compiled object cache types.
Definition: Installer.php:864
Installer\getExistingLocalSettings
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
Definition: Installer.php:593
Installer\envCheckPath
envCheckPath()
Environment check to inform user which paths we've assumed.
Definition: Installer.php:981
Installer\doGenerateKeys
doGenerateKeys( $keys)
Generate a secret value for variables using our CryptRand generator.
Definition: Installer.php:1621
$lines
$lines
Definition: router.php:61
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
Installer\$parserOptions
ParserOptions $parserOptions
Cached ParserOptions, used by parse().
Definition: Installer.php:94
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
SiteStatsUpdate\factory
static factory(array $deltas)
Definition: SiteStatsUpdate.php:66
GlobalVarConfig
Accesses configuration settings from $GLOBALS.
Definition: GlobalVarConfig.php:28
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
settings
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration settings
Definition: globals.txt:37
$wgExternalLinkTarget
$wgExternalLinkTarget
Set a default target for external links, e.g.
Definition: DefaultSettings.php:4351
Installer\$dbTypes
static array $dbTypes
Known database types.
Definition: Installer.php:105
Installer\getVar
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:538
WikitextContent
Content object for wiki text pages.
Definition: WikitextContent.php:33
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
Installer\restoreLinkPopups
restoreLinkPopups()
Definition: Installer.php:719
Installer\getDefaultSkin
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings,...
Definition: Installer.php:1434
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:108
$fname
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition: Setup.php:112
Installer\findExtensions
findExtensions( $directory='extensions')
Finds extensions that follow the format /$directory/Name/Name.php, and returns an array containing th...
Definition: Installer.php:1298
Http\get
static get( $url, $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'GET' )
Definition: Http.php:98
Installer\getInstallerConfig
static getInstallerConfig(Config $baseConfig)
Constructs a Config object that contains configuration settings that should be overwritten for the in...
Definition: Installer.php:364
$line
$line
Definition: cdb.php:59
$value
$value
Definition: styleTest.css.php:45
Installer\$envPreps
array $envPreps
A list of environment preparation methods called by doEnvironmentPreps().
Definition: Installer.php:148
$wgExtensionDirectory
$wgExtensionDirectory
Filesystem extensions directory.
Definition: DefaultSettings.php:243
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
Installer\$installSteps
array $installSteps
The actual list of installation steps.
Definition: Installer.php:234
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:2019
Installer\doEnvironmentPreps
doEnvironmentPreps()
Definition: Installer.php:512
Installer\readExtension
readExtension( $fullJsonFile, $extDeps=[], $skinDeps=[])
Definition: Installer.php:1357
CACHE_ANYTHING
const CACHE_ANYTHING
Definition: Defines.php:111
Installer\getDBInstaller
getDBInstaller( $type=false)
Get an instance of DatabaseInstaller for the specified DB type.
Definition: Installer.php:573
DatabaseInstaller
Base class for DBMS-specific installation helper classes.
Definition: DatabaseInstaller.php:33
Installer\envCheckDB
envCheckDB()
Environment check for DB types.
Definition: Installer.php:758
Installer\getInstallSteps
getInstallSteps(DatabaseInstaller $installer)
Get an array of install steps.
Definition: Installer.php:1512
$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. '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:1255
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:434
$wgAutoloadClasses
$wgAutoloadClasses
Array mapping class names to filenames, for autoloading.
Definition: DefaultSettings.php:7350
Installer\$compiledDBs
array $compiledDBs
List of detected DBs, access using getCompiledDBs().
Definition: Installer.php:66
Installer\doEnvironmentChecks
doEnvironmentChecks()
Do initial checks of the PHP environment.
Definition: Installer.php:483
EDIT_NEW
const EDIT_NEW
Definition: Defines.php:162
Installer\envCheckGraphics
envCheckGraphics()
Environment check for ImageMagick and GD.
Definition: Installer.php:920
wfShorthandToInteger
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
Definition: GlobalFunctions.php:3094
Installer\apacheModulePresent
static apacheModulePresent( $moduleName)
Checks for presence of an Apache module.
Definition: Installer.php:1258
PhpXmlBugTester
Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
Definition: PhpBugTests.php:32
Title
Represents a title within MediaWiki.
Definition: Title.php:39
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
Installer\envCheckPCRE
envCheckPCRE()
Environment check for the PCRE module.
Definition: Installer.php:816
Parser\stripOuterParagraph
static stripOuterParagraph( $html)
Strip outer.
Definition: Parser.php:6141
Installer\getParserOptions
getParserOptions()
Definition: Installer.php:711
MWHttpRequest\canMakeRequests
static canMakeRequests()
Simple function to test if we can make any sort of requests at all, using cURL or fopen()
Definition: MWHttpRequest.php:170
$path
$path
Definition: NoLocalSettings.php:25
Installer\envCheck64Bit
envCheck64Bit()
Checks if we're running on 64 bit or not.
Definition: Installer.php:1111
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:22
Installer\$licenses
array $licenses
License types.
Definition: Installer.php:284
Installer\disableTimeLimit
disableTimeLimit()
Disable the time limit for execution.
Definition: Installer.php:1810
$keys
$keys
Definition: testCompression.php:67
$source
$source
Definition: mwdoc-filter.php:46
Installer\envCheckServer
envCheckServer()
Environment check to inform user which server we've assumed.
Definition: Installer.php:968
Installer
Base installer class.
Definition: Installer.php:46
Installer\MINIMUM_PCRE_VERSION
const MINIMUM_PCRE_VERSION
The oldest version of PCRE we can support.
Definition: Installer.php:54
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:183
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:56
ExecutableFinder\findInDefaultPaths
static findInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Definition: ExecutableFinder.php:96
Installer\getDBTypes
static getDBTypes()
Get a list of known DB types.
Definition: Installer.php:466
Installer\disableLinkPopups
disableLinkPopups()
Definition: Installer.php:715
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:25
Installer\$mediaWikiAnnounceUrl
$mediaWikiAnnounceUrl
URL to mediawiki-announce subscription.
Definition: Installer.php:321
wfIsHHVM
wfIsHHVM()
Check if we are running under HHVM.
Definition: GlobalFunctions.php:2032
$IP
$IP
Definition: WebStart.php:52
Installer\includeExtensions
includeExtensions()
Installs the auto-detected extensions.
Definition: Installer.php:1448
$ext
$ext
Definition: router.php:55
$wgStyleDirectory
$wgStyleDirectory
Filesystem stylesheets directory.
Definition: DefaultSettings.php:250
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
Installer\envCheckGit
envCheckGit()
Search for git.
Definition: Installer.php:946
Installer\getDocUrl
getDocUrl( $page)
Overridden by WebInstaller to provide lastPage parameters.
Definition: Installer.php:1285
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6
Installer\subscribeToMediaWikiAnnounce
subscribeToMediaWikiAnnounce(Status $s)
Definition: Installer.php:1690
Installer\unicodeChar
unicodeChar( $c)
Convert a hex string representing a Unicode code point to that code point.
Definition: Installer.php:1124
CACHE_DB
const CACHE_DB
Definition: Defines.php:113
MWHttpRequest\factory
static factory( $url, array $options=null, $caller=__METHOD__)
Generate a new request object Deprecated:
Definition: MWHttpRequest.php:184
Installer\maybeGetWebserverPrimaryGroup
static maybeGetWebserverPrimaryGroup()
On POSIX systems return the primary group of the webserver we're running under.
Definition: Installer.php:661
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2171
Installer\$defaultVarNames
array $defaultVarNames
MediaWiki configuration globals that will eventually be passed through to LocalSettings....
Definition: Installer.php:160
Installer\getDBInstallerClass
static getDBInstallerClass( $type)
Get the DatabaseInstaller class name for this type.
Definition: Installer.php:562
Installer\$envChecks
array $envChecks
A list of environment check methods called by doEnvironmentChecks().
Definition: Installer.php:124
$type
$type
Definition: testCompression.php:48
Installer\envCheckModSecurity
envCheckModSecurity()
Scare user to death if they have mod_security or mod_security2.
Definition: Installer.php:884