MediaWiki  1.29.2
Installer.php
Go to the documentation of this file.
1 <?php
27 
43 abstract class Installer {
44 
51  const MINIMUM_PCRE_VERSION = '7.2';
52 
56  protected $settings;
57 
63  protected $compiledDBs;
64 
70  protected $dbInstallers = [];
71 
77  protected $minMemorySize = 50;
78 
84  protected $parserTitle;
85 
91  protected $parserOptions;
92 
102  protected static $dbTypes = [
103  'mysql',
104  'postgres',
105  'oracle',
106  'mssql',
107  'sqlite',
108  ];
109 
121  protected $envChecks = [
122  'envCheckDB',
123  'envCheckBrokenXML',
124  'envCheckPCRE',
125  'envCheckMemory',
126  'envCheckCache',
127  'envCheckModSecurity',
128  'envCheckDiff3',
129  'envCheckGraphics',
130  'envCheckGit',
131  'envCheckServer',
132  'envCheckPath',
133  'envCheckShellLocale',
134  'envCheckUploadsDirectory',
135  'envCheckLibicu',
136  'envCheckSuhosinMaxValueLength',
137  ];
138 
144  protected $envPreps = [
145  'envPrepServer',
146  'envPrepPath',
147  ];
148 
156  protected $defaultVarNames = [
157  'wgSitename',
158  'wgPasswordSender',
159  'wgLanguageCode',
160  'wgRightsIcon',
161  'wgRightsText',
162  'wgRightsUrl',
163  'wgEnableEmail',
164  'wgEnableUserEmail',
165  'wgEnotifUserTalk',
166  'wgEnotifWatchlist',
167  'wgEmailAuthentication',
168  'wgDBname',
169  'wgDBtype',
170  'wgDiff3',
171  'wgImageMagickConvertCommand',
172  'wgGitBin',
173  'IP',
174  'wgScriptPath',
175  'wgMetaNamespace',
176  'wgDeletedDirectory',
177  'wgEnableUploads',
178  'wgShellLocale',
179  'wgSecretKey',
180  'wgUseInstantCommons',
181  'wgUpgradeKey',
182  'wgDefaultSkin',
183  'wgPingback',
184  ];
185 
193  protected $internalDefaults = [
194  '_UserLang' => 'en',
195  '_Environment' => false,
196  '_RaiseMemory' => false,
197  '_UpgradeDone' => false,
198  '_InstallDone' => false,
199  '_Caches' => [],
200  '_InstallPassword' => '',
201  '_SameAccount' => true,
202  '_CreateDBAccount' => false,
203  '_NamespaceType' => 'site-name',
204  '_AdminName' => '', // will be set later, when the user selects language
205  '_AdminPassword' => '',
206  '_AdminPasswordConfirm' => '',
207  '_AdminEmail' => '',
208  '_Subscribe' => false,
209  '_SkipOptional' => 'continue',
210  '_RightsProfile' => 'wiki',
211  '_LicenseCode' => 'none',
212  '_CCDone' => false,
213  '_Extensions' => [],
214  '_Skins' => [],
215  '_MemCachedServers' => '',
216  '_UpgradeKeySupplied' => false,
217  '_ExistingDBSettings' => false,
218 
219  // $wgLogo is probably wrong (T50084); set something that will work.
220  // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
221  'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
222  'wgAuthenticationTokenVersion' => 1,
223  ];
224 
230  private $installSteps = [];
231 
237  protected $extraInstallSteps = [];
238 
244  protected $objectCaches = [
245  'xcache' => 'xcache_get',
246  'apc' => 'apc_fetch',
247  'apcu' => 'apcu_fetch',
248  'wincache' => 'wincache_ucache_get'
249  ];
250 
256  public $rightsProfiles = [
257  'wiki' => [],
258  'no-anon' => [
259  '*' => [ 'edit' => false ]
260  ],
261  'fishbowl' => [
262  '*' => [
263  'createaccount' => false,
264  'edit' => false,
265  ],
266  ],
267  'private' => [
268  '*' => [
269  'createaccount' => false,
270  'edit' => false,
271  'read' => false,
272  ],
273  ],
274  ];
275 
281  public $licenses = [
282  'cc-by' => [
283  'url' => 'https://creativecommons.org/licenses/by/4.0/',
284  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by.png',
285  ],
286  'cc-by-sa' => [
287  'url' => 'https://creativecommons.org/licenses/by-sa/4.0/',
288  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
289  ],
290  'cc-by-nc-sa' => [
291  'url' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
292  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
293  ],
294  'cc-0' => [
295  'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
296  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-0.png',
297  ],
298  'gfdl' => [
299  'url' => 'https://www.gnu.org/copyleft/fdl.html',
300  'icon' => '$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
301  ],
302  'none' => [
303  'url' => '',
304  'icon' => '',
305  'text' => ''
306  ],
307  'cc-choose' => [
308  // Details will be filled in by the selector.
309  'url' => '',
310  'icon' => '',
311  'text' => '',
312  ],
313  ];
314 
319  'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
320 
325  'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
326  'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
327  'sl', 'sr', 'sv', 'tr', 'uk'
328  ];
329 
337  abstract public function showMessage( $msg /*, ... */ );
338 
343  abstract public function showError( $msg /*, ... */ );
344 
349  abstract public function showStatusMessage( Status $status );
350 
361  public static function getInstallerConfig( Config $baseConfig ) {
362  $configOverrides = new HashConfig();
363 
364  // disable (problematic) object cache types explicitly, preserving all other (working) ones
365  // bug T113843
366  $emptyCache = [ 'class' => 'EmptyBagOStuff' ];
367 
368  $objectCaches = [
369  CACHE_NONE => $emptyCache,
370  CACHE_DB => $emptyCache,
371  CACHE_ANYTHING => $emptyCache,
372  CACHE_MEMCACHED => $emptyCache,
373  ] + $baseConfig->get( 'ObjectCaches' );
374 
375  $configOverrides->set( 'ObjectCaches', $objectCaches );
376 
377  // Load the installer's i18n.
378  $messageDirs = $baseConfig->get( 'MessagesDirs' );
379  $messageDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
380 
381  $configOverrides->set( 'MessagesDirs', $messageDirs );
382 
383  $installerConfig = new MultiConfig( [ $configOverrides, $baseConfig ] );
384 
385  // make sure we use the installer config as the main config
386  $configRegistry = $baseConfig->get( 'ConfigRegistry' );
387  $configRegistry['main'] = function() use ( $installerConfig ) {
388  return $installerConfig;
389  };
390 
391  $configOverrides->set( 'ConfigRegistry', $configRegistry );
392 
393  return $installerConfig;
394  }
395 
399  public function __construct() {
401 
402  $defaultConfig = new GlobalVarConfig(); // all the stuff from DefaultSettings.php
403  $installerConfig = self::getInstallerConfig( $defaultConfig );
404 
405  // Reset all services and inject config overrides
407 
408  // Don't attempt to load user language options (T126177)
409  // This will be overridden in the web installer with the user-specified language
410  RequestContext::getMain()->setLanguage( 'en' );
411 
412  // Disable the i18n cache
413  // TODO: manage LocalisationCache singleton in MediaWikiServices
414  Language::getLocalisationCache()->disableBackend();
415 
416  // Disable all global services, since we don't have any configuration yet!
418 
419  // Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
420  // SqlBagOStuff will then throw since we just disabled wfGetDB)
421  $wgObjectCaches = MediaWikiServices::getInstance()->getMainConfig()->get( 'ObjectCaches' );
423 
424  // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
425  $wgUser = User::newFromId( 0 );
426  RequestContext::getMain()->setUser( $wgUser );
427 
429 
430  foreach ( $this->defaultVarNames as $var ) {
431  $this->settings[$var] = $GLOBALS[$var];
432  }
433 
434  $this->doEnvironmentPreps();
435 
436  $this->compiledDBs = [];
437  foreach ( self::getDBTypes() as $type ) {
438  $installer = $this->getDBInstaller( $type );
439 
440  if ( !$installer->isCompiled() ) {
441  continue;
442  }
443  $this->compiledDBs[] = $type;
444  }
445 
446  $this->parserTitle = Title::newFromText( 'Installer' );
447  $this->parserOptions = new ParserOptions( $wgUser ); // language will be wrong :(
448  $this->parserOptions->setEditSection( false );
449  // Don't try to access DB before user language is initialised
450  $this->setParserLanguage( Language::factory( 'en' ) );
451  }
452 
458  public static function getDBTypes() {
459  return self::$dbTypes;
460  }
461 
475  public function doEnvironmentChecks() {
476  // Php version has already been checked by entry scripts
477  // Show message here for information purposes
478  if ( wfIsHHVM() ) {
479  $this->showMessage( 'config-env-hhvm', HHVM_VERSION );
480  } else {
481  $this->showMessage( 'config-env-php', PHP_VERSION );
482  }
483 
484  $good = true;
485  // Must go here because an old version of PCRE can prevent other checks from completing
486  list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
487  if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
488  $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
489  $good = false;
490  } else {
491  foreach ( $this->envChecks as $check ) {
492  $status = $this->$check();
493  if ( $status === false ) {
494  $good = false;
495  }
496  }
497  }
498 
499  $this->setVar( '_Environment', $good );
500 
501  return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
502  }
503 
504  public function doEnvironmentPreps() {
505  foreach ( $this->envPreps as $prep ) {
506  $this->$prep();
507  }
508  }
509 
516  public function setVar( $name, $value ) {
517  $this->settings[$name] = $value;
518  }
519 
530  public function getVar( $name, $default = null ) {
531  if ( !isset( $this->settings[$name] ) ) {
532  return $default;
533  } else {
534  return $this->settings[$name];
535  }
536  }
537 
543  public function getCompiledDBs() {
544  return $this->compiledDBs;
545  }
546 
554  public function getDBInstaller( $type = false ) {
555  if ( !$type ) {
556  $type = $this->getVar( 'wgDBtype' );
557  }
558 
559  $type = strtolower( $type );
560 
561  if ( !isset( $this->dbInstallers[$type] ) ) {
562  $class = ucfirst( $type ) . 'Installer';
563  $this->dbInstallers[$type] = new $class( $this );
564  }
565 
566  return $this->dbInstallers[$type];
567  }
568 
574  public static function getExistingLocalSettings() {
575  global $IP;
576 
577  // You might be wondering why this is here. Well if you don't do this
578  // then some poorly-formed extensions try to call their own classes
579  // after immediately registering them. We really need to get extension
580  // registration out of the global scope and into a real format.
581  // @see https://phabricator.wikimedia.org/T69440
583  $wgAutoloadClasses = [];
584 
585  // @codingStandardsIgnoreStart
586  // LocalSettings.php should not call functions, except wfLoadSkin/wfLoadExtensions
587  // Define the required globals here, to ensure, the functions can do it work correctly.
589  // @codingStandardsIgnoreEnd
590 
591  MediaWiki\suppressWarnings();
592  $_lsExists = file_exists( "$IP/LocalSettings.php" );
593  MediaWiki\restoreWarnings();
594 
595  if ( !$_lsExists ) {
596  return false;
597  }
598  unset( $_lsExists );
599 
600  require "$IP/includes/DefaultSettings.php";
601  require "$IP/LocalSettings.php";
602 
603  return get_defined_vars();
604  }
605 
615  public function getFakePassword( $realPassword ) {
616  return str_repeat( '*', strlen( $realPassword ) );
617  }
618 
626  public function setPassword( $name, $value ) {
627  if ( !preg_match( '/^\*+$/', $value ) ) {
628  $this->setVar( $name, $value );
629  }
630  }
631 
643  public static function maybeGetWebserverPrimaryGroup() {
644  if ( !function_exists( 'posix_getegid' ) || !function_exists( 'posix_getpwuid' ) ) {
645  # I don't know this, this isn't UNIX.
646  return null;
647  }
648 
649  # posix_getegid() *not* getmygid() because we want the group of the webserver,
650  # not whoever owns the current script.
651  $gid = posix_getegid();
652  $group = posix_getpwuid( $gid )['name'];
653 
654  return $group;
655  }
656 
673  public function parse( $text, $lineStart = false ) {
675 
676  try {
677  $out = $wgParser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
678  $html = $out->getText();
679  } catch ( MediaWiki\Services\ServiceDisabledException $e ) {
680  $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
681 
682  if ( !empty( $this->debug ) ) {
683  $html .= "<!--\n" . $e->getTraceAsString() . "\n-->";
684  }
685  }
686 
687  return $html;
688  }
689 
693  public function getParserOptions() {
694  return $this->parserOptions;
695  }
696 
697  public function disableLinkPopups() {
698  $this->parserOptions->setExternalLinkTarget( false );
699  }
700 
701  public function restoreLinkPopups() {
702  global $wgExternalLinkTarget;
703  $this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
704  }
705 
714  public function populateSiteStats( DatabaseInstaller $installer ) {
715  $status = $installer->getConnection();
716  if ( !$status->isOK() ) {
717  return $status;
718  }
719  $status->value->insert(
720  'site_stats',
721  [
722  'ss_row_id' => 1,
723  'ss_total_edits' => 0,
724  'ss_good_articles' => 0,
725  'ss_total_pages' => 0,
726  'ss_users' => 0,
727  'ss_active_users' => 0,
728  'ss_images' => 0
729  ],
730  __METHOD__, 'IGNORE'
731  );
732 
733  return Status::newGood();
734  }
735 
740  protected function envCheckDB() {
741  global $wgLang;
742 
743  $allNames = [];
744 
745  // Messages: config-type-mysql, config-type-postgres, config-type-oracle,
746  // config-type-sqlite
747  foreach ( self::getDBTypes() as $name ) {
748  $allNames[] = wfMessage( "config-type-$name" )->text();
749  }
750 
751  $databases = $this->getCompiledDBs();
752 
753  $databases = array_flip( $databases );
754  foreach ( array_keys( $databases ) as $db ) {
755  $installer = $this->getDBInstaller( $db );
756  $status = $installer->checkPrerequisites();
757  if ( !$status->isGood() ) {
758  $this->showStatusMessage( $status );
759  }
760  if ( !$status->isOK() ) {
761  unset( $databases[$db] );
762  }
763  }
764  $databases = array_flip( $databases );
765  if ( !$databases ) {
766  $this->showError( 'config-no-db', $wgLang->commaList( $allNames ), count( $allNames ) );
767 
768  // @todo FIXME: This only works for the web installer!
769  return false;
770  }
771 
772  return true;
773  }
774 
779  protected function envCheckBrokenXML() {
780  $test = new PhpXmlBugTester();
781  if ( !$test->ok ) {
782  $this->showError( 'config-brokenlibxml' );
783 
784  return false;
785  }
786 
787  return true;
788  }
789 
798  protected function envCheckPCRE() {
799  MediaWiki\suppressWarnings();
800  $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
801  // Need to check for \p support too, as PCRE can be compiled
802  // with utf8 support, but not unicode property support.
803  // check that \p{Zs} (space separators) matches
804  // U+3000 (Ideographic space)
805  $regexprop = preg_replace( '/\p{Zs}/u', '', "-\xE3\x80\x80-" );
806  MediaWiki\restoreWarnings();
807  if ( $regexd != '--' || $regexprop != '--' ) {
808  $this->showError( 'config-pcre-no-utf8' );
809 
810  return false;
811  }
812 
813  return true;
814  }
815 
820  protected function envCheckMemory() {
821  $limit = ini_get( 'memory_limit' );
822 
823  if ( !$limit || $limit == -1 ) {
824  return true;
825  }
826 
828 
829  if ( $n < $this->minMemorySize * 1024 * 1024 ) {
830  $newLimit = "{$this->minMemorySize}M";
831 
832  if ( ini_set( "memory_limit", $newLimit ) === false ) {
833  $this->showMessage( 'config-memory-bad', $limit );
834  } else {
835  $this->showMessage( 'config-memory-raised', $limit, $newLimit );
836  $this->setVar( '_RaiseMemory', true );
837  }
838  }
839 
840  return true;
841  }
842 
846  protected function envCheckCache() {
847  $caches = [];
848  foreach ( $this->objectCaches as $name => $function ) {
849  if ( function_exists( $function ) ) {
850  if ( $name == 'xcache' && !wfIniGetBool( 'xcache.var_size' ) ) {
851  continue;
852  }
853  $caches[$name] = true;
854  }
855  }
856 
857  if ( !$caches ) {
858  $key = 'config-no-cache-apcu';
859  $this->showMessage( $key );
860  }
861 
862  $this->setVar( '_Caches', $caches );
863  }
864 
869  protected function envCheckModSecurity() {
870  if ( self::apacheModulePresent( 'mod_security' )
871  || self::apacheModulePresent( 'mod_security2' ) ) {
872  $this->showMessage( 'config-mod-security' );
873  }
874 
875  return true;
876  }
877 
882  protected function envCheckDiff3() {
883  $names = [ "gdiff3", "diff3", "diff3.exe" ];
884  $versionInfo = [ '$1 --version 2>&1', 'GNU diffutils' ];
885 
886  $diff3 = self::locateExecutableInDefaultPaths( $names, $versionInfo );
887 
888  if ( $diff3 ) {
889  $this->setVar( 'wgDiff3', $diff3 );
890  } else {
891  $this->setVar( 'wgDiff3', false );
892  $this->showMessage( 'config-diff3-bad' );
893  }
894 
895  return true;
896  }
897 
902  protected function envCheckGraphics() {
903  $names = [ wfIsWindows() ? 'convert.exe' : 'convert' ];
904  $versionInfo = [ '$1 -version', 'ImageMagick' ];
905  $convert = self::locateExecutableInDefaultPaths( $names, $versionInfo );
906 
907  $this->setVar( 'wgImageMagickConvertCommand', '' );
908  if ( $convert ) {
909  $this->setVar( 'wgImageMagickConvertCommand', $convert );
910  $this->showMessage( 'config-imagemagick', $convert );
911 
912  return true;
913  } elseif ( function_exists( 'imagejpeg' ) ) {
914  $this->showMessage( 'config-gd' );
915  } else {
916  $this->showMessage( 'config-no-scaling' );
917  }
918 
919  return true;
920  }
921 
928  protected function envCheckGit() {
929  $names = [ wfIsWindows() ? 'git.exe' : 'git' ];
930  $versionInfo = [ '$1 --version', 'git version' ];
931 
932  $git = self::locateExecutableInDefaultPaths( $names, $versionInfo );
933 
934  if ( $git ) {
935  $this->setVar( 'wgGitBin', $git );
936  $this->showMessage( 'config-git', $git );
937  } else {
938  $this->setVar( 'wgGitBin', false );
939  $this->showMessage( 'config-git-bad' );
940  }
941 
942  return true;
943  }
944 
950  protected function envCheckServer() {
951  $server = $this->envGetDefaultServer();
952  if ( $server !== null ) {
953  $this->showMessage( 'config-using-server', $server );
954  }
955  return true;
956  }
957 
963  protected function envCheckPath() {
964  $this->showMessage(
965  'config-using-uri',
966  $this->getVar( 'wgServer' ),
967  $this->getVar( 'wgScriptPath' )
968  );
969  return true;
970  }
971 
976  protected function envCheckShellLocale() {
977  $os = php_uname( 's' );
978  $supported = [ 'Linux', 'SunOS', 'HP-UX', 'Darwin' ]; # Tested these
979 
980  if ( !in_array( $os, $supported ) ) {
981  return true;
982  }
983 
984  # Get a list of available locales.
985  $ret = false;
986  $lines = wfShellExec( '/usr/bin/locale -a', $ret );
987 
988  if ( $ret ) {
989  return true;
990  }
991 
992  $lines = array_map( 'trim', explode( "\n", $lines ) );
993  $candidatesByLocale = [];
994  $candidatesByLang = [];
995 
996  foreach ( $lines as $line ) {
997  if ( $line === '' ) {
998  continue;
999  }
1000 
1001  if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
1002  continue;
1003  }
1004 
1005  list( , $lang, , , ) = $m;
1006 
1007  $candidatesByLocale[$m[0]] = $m;
1008  $candidatesByLang[$lang][] = $m;
1009  }
1010 
1011  # Try the current value of LANG.
1012  if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
1013  $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
1014 
1015  return true;
1016  }
1017 
1018  # Try the most common ones.
1019  $commonLocales = [ 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ];
1020  foreach ( $commonLocales as $commonLocale ) {
1021  if ( isset( $candidatesByLocale[$commonLocale] ) ) {
1022  $this->setVar( 'wgShellLocale', $commonLocale );
1023 
1024  return true;
1025  }
1026  }
1027 
1028  # Is there an available locale in the Wiki's language?
1029  $wikiLang = $this->getVar( 'wgLanguageCode' );
1030 
1031  if ( isset( $candidatesByLang[$wikiLang] ) ) {
1032  $m = reset( $candidatesByLang[$wikiLang] );
1033  $this->setVar( 'wgShellLocale', $m[0] );
1034 
1035  return true;
1036  }
1037 
1038  # Are there any at all?
1039  if ( count( $candidatesByLocale ) ) {
1040  $m = reset( $candidatesByLocale );
1041  $this->setVar( 'wgShellLocale', $m[0] );
1042 
1043  return true;
1044  }
1045 
1046  # Give up.
1047  return true;
1048  }
1049 
1054  protected function envCheckUploadsDirectory() {
1055  global $IP;
1056 
1057  $dir = $IP . '/images/';
1058  $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
1059  $safe = !$this->dirIsExecutable( $dir, $url );
1060 
1061  if ( !$safe ) {
1062  $this->showMessage( 'config-uploads-not-safe', $dir );
1063  }
1064 
1065  return true;
1066  }
1067 
1073  protected function envCheckSuhosinMaxValueLength() {
1074  $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
1075  if ( $maxValueLength > 0 && $maxValueLength < 1024 ) {
1076  // Only warn if the value is below the sane 1024
1077  $this->showMessage( 'config-suhosin-max-value-length', $maxValueLength );
1078  }
1079 
1080  return true;
1081  }
1082 
1088  protected function unicodeChar( $c ) {
1089  $c = hexdec( $c );
1090  if ( $c <= 0x7F ) {
1091  return chr( $c );
1092  } elseif ( $c <= 0x7FF ) {
1093  return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
1094  } elseif ( $c <= 0xFFFF ) {
1095  return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F ) .
1096  chr( 0x80 | $c & 0x3F );
1097  } elseif ( $c <= 0x10FFFF ) {
1098  return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F ) .
1099  chr( 0x80 | $c >> 6 & 0x3F ) .
1100  chr( 0x80 | $c & 0x3F );
1101  } else {
1102  return false;
1103  }
1104  }
1105 
1109  protected function envCheckLibicu() {
1117  $not_normal_c = $this->unicodeChar( "FA6C" );
1118  $normal_c = $this->unicodeChar( "242EE" );
1119 
1120  $useNormalizer = 'php';
1121  $needsUpdate = false;
1122 
1123  if ( function_exists( 'normalizer_normalize' ) ) {
1124  $useNormalizer = 'intl';
1125  $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
1126  if ( $intl !== $normal_c ) {
1127  $needsUpdate = true;
1128  }
1129  }
1130 
1131  // Uses messages 'config-unicode-using-php' and 'config-unicode-using-intl'
1132  if ( $useNormalizer === 'php' ) {
1133  $this->showMessage( 'config-unicode-pure-php-warning' );
1134  } else {
1135  $this->showMessage( 'config-unicode-using-' . $useNormalizer );
1136  if ( $needsUpdate ) {
1137  $this->showMessage( 'config-unicode-update-warning' );
1138  }
1139  }
1140  }
1141 
1145  protected function envPrepServer() {
1146  $server = $this->envGetDefaultServer();
1147  if ( $server !== null ) {
1148  $this->setVar( 'wgServer', $server );
1149  }
1150  }
1151 
1156  abstract protected function envGetDefaultServer();
1157 
1161  protected function envPrepPath() {
1162  global $IP;
1163  $IP = dirname( dirname( __DIR__ ) );
1164  $this->setVar( 'IP', $IP );
1165  }
1166 
1174  protected static function getPossibleBinPaths() {
1175  return array_merge(
1176  [ '/usr/bin', '/usr/local/bin', '/opt/csw/bin',
1177  '/usr/gnu/bin', '/usr/sfw/bin', '/sw/bin', '/opt/local/bin' ],
1178  explode( PATH_SEPARATOR, getenv( 'PATH' ) )
1179  );
1180  }
1181 
1199  public static function locateExecutable( $path, $names, $versionInfo = false ) {
1200  if ( !is_array( $names ) ) {
1201  $names = [ $names ];
1202  }
1203 
1204  foreach ( $names as $name ) {
1205  $command = $path . DIRECTORY_SEPARATOR . $name;
1206 
1207  MediaWiki\suppressWarnings();
1208  $file_exists = is_executable( $command );
1209  MediaWiki\restoreWarnings();
1210 
1211  if ( $file_exists ) {
1212  if ( !$versionInfo ) {
1213  return $command;
1214  }
1215 
1216  $file = str_replace( '$1', wfEscapeShellArg( $command ), $versionInfo[0] );
1217  if ( strstr( wfShellExec( $file ), $versionInfo[1] ) !== false ) {
1218  return $command;
1219  }
1220  }
1221  }
1222 
1223  return false;
1224  }
1225 
1238  public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
1239  foreach ( self::getPossibleBinPaths() as $path ) {
1240  $exe = self::locateExecutable( $path, $names, $versionInfo );
1241  if ( $exe !== false ) {
1242  return $exe;
1243  }
1244  }
1245 
1246  return false;
1247  }
1248 
1257  public function dirIsExecutable( $dir, $url ) {
1258  $scriptTypes = [
1259  'php' => [
1260  "<?php echo 'ex' . 'ec';",
1261  "#!/var/env php5\n<?php echo 'ex' . 'ec';",
1262  ],
1263  ];
1264 
1265  // it would be good to check other popular languages here, but it'll be slow.
1266 
1267  MediaWiki\suppressWarnings();
1268 
1269  foreach ( $scriptTypes as $ext => $contents ) {
1270  foreach ( $contents as $source ) {
1271  $file = 'exectest.' . $ext;
1272 
1273  if ( !file_put_contents( $dir . $file, $source ) ) {
1274  break;
1275  }
1276 
1277  try {
1278  $text = Http::get( $url . $file, [ 'timeout' => 3 ], __METHOD__ );
1279  } catch ( Exception $e ) {
1280  // Http::get throws with allow_url_fopen = false and no curl extension.
1281  $text = null;
1282  }
1283  unlink( $dir . $file );
1284 
1285  if ( $text == 'exec' ) {
1286  MediaWiki\restoreWarnings();
1287 
1288  return $ext;
1289  }
1290  }
1291  }
1292 
1293  MediaWiki\restoreWarnings();
1294 
1295  return false;
1296  }
1297 
1304  public static function apacheModulePresent( $moduleName ) {
1305  if ( function_exists( 'apache_get_modules' ) && in_array( $moduleName, apache_get_modules() ) ) {
1306  return true;
1307  }
1308  // try it the hard way
1309  ob_start();
1310  phpinfo( INFO_MODULES );
1311  $info = ob_get_clean();
1312 
1313  return strpos( $info, $moduleName ) !== false;
1314  }
1315 
1321  public function setParserLanguage( $lang ) {
1322  $this->parserOptions->setTargetLanguage( $lang );
1323  $this->parserOptions->setUserLang( $lang );
1324  }
1325 
1331  protected function getDocUrl( $page ) {
1332  return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1333  }
1334 
1344  public function findExtensions( $directory = 'extensions' ) {
1345  if ( $this->getVar( 'IP' ) === null ) {
1346  return [];
1347  }
1348 
1349  $extDir = $this->getVar( 'IP' ) . '/' . $directory;
1350  if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
1351  return [];
1352  }
1353 
1354  // extensions -> extension.json, skins -> skin.json
1355  $jsonFile = substr( $directory, 0, strlen( $directory ) -1 ) . '.json';
1356 
1357  $dh = opendir( $extDir );
1358  $exts = [];
1359  while ( ( $file = readdir( $dh ) ) !== false ) {
1360  if ( !is_dir( "$extDir/$file" ) ) {
1361  continue;
1362  }
1363  if ( file_exists( "$extDir/$file/$jsonFile" ) || file_exists( "$extDir/$file/$file.php" ) ) {
1364  $exts[] = $file;
1365  }
1366  }
1367  closedir( $dh );
1368  natcasesort( $exts );
1369 
1370  return $exts;
1371  }
1372 
1381  public function getDefaultSkin( array $skinNames ) {
1382  $defaultSkin = $GLOBALS['wgDefaultSkin'];
1383  if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) {
1384  return $defaultSkin;
1385  } else {
1386  return $skinNames[0];
1387  }
1388  }
1389 
1395  protected function includeExtensions() {
1396  global $IP;
1397  $exts = $this->getVar( '_Extensions' );
1398  $IP = $this->getVar( 'IP' );
1399 
1409  $wgAutoloadClasses = [];
1410  $queue = [];
1411 
1412  require "$IP/includes/DefaultSettings.php";
1413 
1414  foreach ( $exts as $e ) {
1415  if ( file_exists( "$IP/extensions/$e/extension.json" ) ) {
1416  $queue["$IP/extensions/$e/extension.json"] = 1;
1417  } else {
1418  require_once "$IP/extensions/$e/$e.php";
1419  }
1420  }
1421 
1422  $registry = new ExtensionRegistry();
1423  $data = $registry->readFromQueue( $queue );
1424  $wgAutoloadClasses += $data['autoload'];
1425 
1426  $hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
1428  $wgHooks['LoadExtensionSchemaUpdates'] : [];
1429 
1430  if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
1431  $hooksWeWant = array_merge_recursive(
1432  $hooksWeWant,
1433  $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']
1434  );
1435  }
1436  // Unset everyone else's hooks. Lord knows what someone might be doing
1437  // in ParserFirstCallInit (see T29171)
1438  $GLOBALS['wgHooks'] = [ 'LoadExtensionSchemaUpdates' => $hooksWeWant ];
1439 
1440  return Status::newGood();
1441  }
1442 
1455  protected function getInstallSteps( DatabaseInstaller $installer ) {
1456  $coreInstallSteps = [
1457  [ 'name' => 'database', 'callback' => [ $installer, 'setupDatabase' ] ],
1458  [ 'name' => 'tables', 'callback' => [ $installer, 'createTables' ] ],
1459  [ 'name' => 'interwiki', 'callback' => [ $installer, 'populateInterwikiTable' ] ],
1460  [ 'name' => 'stats', 'callback' => [ $this, 'populateSiteStats' ] ],
1461  [ 'name' => 'keys', 'callback' => [ $this, 'generateKeys' ] ],
1462  [ 'name' => 'updates', 'callback' => [ $installer, 'insertUpdateKeys' ] ],
1463  [ 'name' => 'sysop', 'callback' => [ $this, 'createSysop' ] ],
1464  [ 'name' => 'mainpage', 'callback' => [ $this, 'createMainpage' ] ],
1465  ];
1466 
1467  // Build the array of install steps starting from the core install list,
1468  // then adding any callbacks that wanted to attach after a given step
1469  foreach ( $coreInstallSteps as $step ) {
1470  $this->installSteps[] = $step;
1471  if ( isset( $this->extraInstallSteps[$step['name']] ) ) {
1472  $this->installSteps = array_merge(
1473  $this->installSteps,
1474  $this->extraInstallSteps[$step['name']]
1475  );
1476  }
1477  }
1478 
1479  // Prepend any steps that want to be at the beginning
1480  if ( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
1481  $this->installSteps = array_merge(
1482  $this->extraInstallSteps['BEGINNING'],
1483  $this->installSteps
1484  );
1485  }
1486 
1487  // Extensions should always go first, chance to tie into hooks and such
1488  if ( count( $this->getVar( '_Extensions' ) ) ) {
1489  array_unshift( $this->installSteps,
1490  [ 'name' => 'extensions', 'callback' => [ $this, 'includeExtensions' ] ]
1491  );
1492  $this->installSteps[] = [
1493  'name' => 'extension-tables',
1494  'callback' => [ $installer, 'createExtensionTables' ]
1495  ];
1496  }
1497 
1498  return $this->installSteps;
1499  }
1500 
1509  public function performInstallation( $startCB, $endCB ) {
1510  $installResults = [];
1511  $installer = $this->getDBInstaller();
1512  $installer->preInstall();
1513  $steps = $this->getInstallSteps( $installer );
1514  foreach ( $steps as $stepObj ) {
1515  $name = $stepObj['name'];
1516  call_user_func_array( $startCB, [ $name ] );
1517 
1518  // Perform the callback step
1519  $status = call_user_func( $stepObj['callback'], $installer );
1520 
1521  // Output and save the results
1522  call_user_func( $endCB, $name, $status );
1523  $installResults[$name] = $status;
1524 
1525  // If we've hit some sort of fatal, we need to bail.
1526  // Callback already had a chance to do output above.
1527  if ( !$status->isOk() ) {
1528  break;
1529  }
1530  }
1531  if ( $status->isOk() ) {
1532  $this->setVar( '_InstallDone', true );
1533  }
1534 
1535  return $installResults;
1536  }
1537 
1543  public function generateKeys() {
1544  $keys = [ 'wgSecretKey' => 64 ];
1545  if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
1546  $keys['wgUpgradeKey'] = 16;
1547  }
1548 
1549  return $this->doGenerateKeys( $keys );
1550  }
1551 
1559  protected function doGenerateKeys( $keys ) {
1561 
1562  $strong = true;
1563  foreach ( $keys as $name => $length ) {
1564  $secretKey = MWCryptRand::generateHex( $length, true );
1565  if ( !MWCryptRand::wasStrong() ) {
1566  $strong = false;
1567  }
1568 
1569  $this->setVar( $name, $secretKey );
1570  }
1571 
1572  if ( !$strong ) {
1573  $names = array_keys( $keys );
1574  $names = preg_replace( '/^(.*)$/', '\$$1', $names );
1575  global $wgLang;
1576  $status->warning( 'config-insecure-keys', $wgLang->listToText( $names ), count( $names ) );
1577  }
1578 
1579  return $status;
1580  }
1581 
1587  protected function createSysop() {
1588  $name = $this->getVar( '_AdminName' );
1590 
1591  if ( !$user ) {
1592  // We should've validated this earlier anyway!
1593  return Status::newFatal( 'config-admin-error-user', $name );
1594  }
1595 
1596  if ( $user->idForName() == 0 ) {
1597  $user->addToDatabase();
1598 
1599  try {
1600  $user->setPassword( $this->getVar( '_AdminPassword' ) );
1601  } catch ( PasswordError $pwe ) {
1602  return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
1603  }
1604 
1605  $user->addGroup( 'sysop' );
1606  $user->addGroup( 'bureaucrat' );
1607  if ( $this->getVar( '_AdminEmail' ) ) {
1608  $user->setEmail( $this->getVar( '_AdminEmail' ) );
1609  }
1610  $user->saveSettings();
1611 
1612  // Update user count
1613  $ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
1614  $ssUpdate->doUpdate();
1615  }
1617 
1618  if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
1620  }
1621 
1622  return $status;
1623  }
1624 
1629  $params = [
1630  'email' => $this->getVar( '_AdminEmail' ),
1631  'language' => 'en',
1632  'digest' => 0
1633  ];
1634 
1635  // Mailman doesn't support as many languages as we do, so check to make
1636  // sure their selected language is available
1637  $myLang = $this->getVar( '_UserLang' );
1638  if ( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
1639  $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
1640  $params['language'] = $myLang;
1641  }
1642 
1644  $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
1645  [ 'method' => 'POST', 'postData' => $params ], __METHOD__ )->execute();
1646  if ( !$res->isOK() ) {
1647  $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
1648  }
1649  } else {
1650  $s->warning( 'config-install-subscribe-notpossible' );
1651  }
1652  }
1653 
1660  protected function createMainpage( DatabaseInstaller $installer ) {
1663  if ( $title->exists() ) {
1664  $status->warning( 'config-install-mainpage-exists' );
1665  return $status;
1666  }
1667  try {
1669  $content = new WikitextContent(
1670  wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
1671  wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
1672  );
1673 
1674  $status = $page->doEditContent( $content,
1675  '',
1676  EDIT_NEW,
1677  false,
1678  User::newFromName( 'MediaWiki default' )
1679  );
1680  } catch ( Exception $e ) {
1681  // using raw, because $wgShowExceptionDetails can not be set yet
1682  $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
1683  }
1684 
1685  return $status;
1686  }
1687 
1691  public static function overrideConfig() {
1692  // Use PHP's built-in session handling, since MediaWiki's
1693  // SessionHandler can't work before we have an object cache set up.
1694  define( 'MW_NO_SESSION_HANDLER', 1 );
1695 
1696  // Don't access the database
1697  $GLOBALS['wgUseDatabaseMessages'] = false;
1698  // Don't cache langconv tables
1699  $GLOBALS['wgLanguageConverterCacheType'] = CACHE_NONE;
1700  // Debug-friendly
1701  $GLOBALS['wgShowExceptionDetails'] = true;
1702  // Don't break forms
1703  $GLOBALS['wgExternalLinkTarget'] = '_blank';
1704 
1705  // Extended debugging
1706  $GLOBALS['wgShowSQLErrors'] = true;
1707  $GLOBALS['wgShowDBErrorBacktrace'] = true;
1708 
1709  // Allow multiple ob_flush() calls
1710  $GLOBALS['wgDisableOutputCompression'] = true;
1711 
1712  // Use a sensible cookie prefix (not my_wiki)
1713  $GLOBALS['wgCookiePrefix'] = 'mw_installer';
1714 
1715  // Some of the environment checks make shell requests, remove limits
1716  $GLOBALS['wgMaxShellMemory'] = 0;
1717 
1718  // Override the default CookieSessionProvider with a dummy
1719  // implementation that won't stomp on PHP's cookies.
1720  $GLOBALS['wgSessionProviders'] = [
1721  [
1722  'class' => 'InstallerSessionProvider',
1723  'args' => [ [
1724  'priority' => 1,
1725  ] ]
1726  ]
1727  ];
1728 
1729  // Don't try to use any object cache for SessionManager either.
1730  $GLOBALS['wgSessionCacheType'] = CACHE_NONE;
1731  }
1732 
1740  public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
1741  $this->extraInstallSteps[$findStep][] = $callback;
1742  }
1743 
1748  protected function disableTimeLimit() {
1749  MediaWiki\suppressWarnings();
1750  set_time_limit( 0 );
1751  MediaWiki\restoreWarnings();
1752  }
1753 }
Installer\envCheckBrokenXML
envCheckBrokenXML()
Some versions of libxml+PHP break < and > encoding horribly.
Definition: Installer.php:779
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:33
MWHttpRequest\factory
static factory( $url, $options=null, $caller=__METHOD__)
Generate a new request object.
Definition: MWHttpRequest.php:180
Installer\__construct
__construct()
Constructor, always call this from child classes.
Definition: Installer.php:399
$wgUser
$wgUser
Definition: Setup.php:781
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:579
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:265
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
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:1660
Installer\showMessage
showMessage( $msg)
UI interface for displaying a short message The parameters are like parameters to wfMessage().
$wgParser
$wgParser
Definition: Setup.php:796
Installer\parse
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
Definition: Installer.php:673
MultiConfig
Provides a fallback sequence for Config objects.
Definition: MultiConfig.php:28
$wgAutoloadClasses
global $wgAutoloadClasses
Definition: TestsAutoLoader.php:24
$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
captcha-old.count
count
Definition: captcha-old.py:225
$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:25
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:1257
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
CACHE_NONE
const CACHE_NONE
Definition: Defines.php:100
Installer\envCheckLibicu
envCheckLibicu()
Check the libicu version.
Definition: Installer.php:1109
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:559
ExtensionRegistry
ExtensionRegistry class.
Definition: ExtensionRegistry.php:14
CACHE_MEMCACHED
const CACHE_MEMCACHED
Definition: Defines.php:102
Installer\populateSiteStats
populateSiteStats(DatabaseInstaller $installer)
Install step which adds a row to the site_stats table with appropriate initial values.
Definition: Installer.php:714
Installer\$extraInstallSteps
array $extraInstallSteps
Extra steps for installation, for things like DatabaseInstallers to modify.
Definition: Installer.php:237
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
Installer\$rightsProfiles
array $rightsProfiles
User rights profiles.
Definition: Installer.php:256
Installer\envCheckShellLocale
envCheckShellLocale()
Environment check for preferred locale in shell.
Definition: Installer.php:976
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
Installer\envCheckUploadsDirectory
envCheckUploadsDirectory()
Environment check for the permissions of the uploads directory.
Definition: Installer.php:1054
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:63
Installer\$settings
array $settings
Definition: Installer.php:56
Installer\envPrepServer
envPrepServer()
Environment prep for the server hostname.
Definition: Installer.php:1145
$params
$params
Definition: styleTest.css.php:40
Installer\performInstallation
performInstallation( $startCB, $endCB)
Actually perform the installation.
Definition: Installer.php:1509
Installer\$mediaWikiAnnounceLanguages
$mediaWikiAnnounceLanguages
Supported language codes for Mailman.
Definition: Installer.php:324
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:556
$s
$s
Definition: mergeMessageFileList.php:188
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
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
Installer\$dbInstallers
array $dbInstallers
Cached DB installer instances, access using getDBInstaller().
Definition: Installer.php:70
Installer\setParserLanguage
setParserLanguage( $lang)
ParserOptions are constructed before we determined the language, so fix it.
Definition: Installer.php:1321
Installer\addInstallStep
addInstallStep( $callback, $findStep='BEGINNING')
Add an installation step following the given step.
Definition: Installer.php:1740
$type
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition: hooks.txt:2536
Installer\$internalDefaults
array $internalDefaults
Variables that are stored alongside globals, and are used for any configuration of the installation p...
Definition: Installer.php:193
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:626
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:35
Installer\setVar
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:516
Installer\$parserTitle
Title $parserTitle
Cached Title, used by parse().
Definition: Installer.php:84
Installer\$objectCaches
array $objectCaches
Known object cache types and the functions used to test for their existence.
Definition: Installer.php:244
Installer\locateExecutableInDefaultPaths
static locateExecutableInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Definition: Installer.php:1238
Installer\$minMemorySize
int $minMemorySize
Minimum memory size in MB.
Definition: Installer.php:77
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:1691
Installer\createSysop
createSysop()
Create the first user account, grant it sysop and bureaucrat rights.
Definition: Installer.php:1587
Installer\getFakePassword
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
Definition: Installer.php:615
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:1073
Language\getLocalisationCache
static getLocalisationCache()
Get the LocalisationCache instance.
Definition: Language.php:406
Installer\showError
showError( $msg)
Same as showMessage(), but for displaying errors.
$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:1956
Installer\getPossibleBinPaths
static getPossibleBinPaths()
Get an array of likely places we can find executables.
Definition: Installer.php:1174
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
Installer\envPrepPath
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
Definition: Installer.php:1161
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:120
MediaWiki\MediaWikiServices\resetGlobalInstance
static resetGlobalInstance(Config $bootstrapConfig=null, $quick='')
Creates a new instance of MediaWikiServices and sets it as the global default instance.
Definition: MediaWikiServices.php:173
Installer\envCheckDiff3
envCheckDiff3()
Search for GNU diff3.
Definition: Installer.php:882
Installer\generateKeys
generateKeys()
Generate $wgSecretKey.
Definition: Installer.php:1543
$content
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 $content
Definition: hooks.txt:1049
$page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2536
Installer\envCheckMemory
envCheckMemory()
Environment check for available memory.
Definition: Installer.php:820
MediaWiki
A helper class for throttling authentication attempts.
$IP
$IP
Definition: update.php:3
$wgObjectCaches
$wgObjectCaches
Advanced object cache configuration.
Definition: DefaultSettings.php:2272
Installer\getCompiledDBs
getCompiledDBs()
Get a list of DBs supported by current PHP setup.
Definition: Installer.php:543
$limit
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 the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired 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 inclusive $limit
Definition: hooks.txt:1049
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:161
Installer\envCheckCache
envCheckCache()
Environment check for compiled object cache types.
Definition: Installer.php:846
Installer\getExistingLocalSettings
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
Definition: Installer.php:574
Installer\envCheckPath
envCheckPath()
Environment check to inform user which paths we've assumed.
Definition: Installer.php:963
Installer\doGenerateKeys
doGenerateKeys( $keys)
Generate a secret value for variables using our CryptRand generator.
Definition: Installer.php:1559
$lines
$lines
Definition: router.php:67
$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:91
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:93
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:25
SiteStatsUpdate
Class for handling updates to the site_stats table.
Definition: SiteStatsUpdate.php:27
$GLOBALS
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
Definition: Autoload.php:10
MediaWiki\MediaWikiServices\disableStorageBackend
static disableStorageBackend()
Disables all storage layer services.
Definition: MediaWikiServices.php:270
Installer\$dbTypes
static array $dbTypes
Known database types.
Definition: Installer.php:102
Installer\getVar
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:530
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:701
Installer\getDefaultSkin
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings,...
Definition: Installer.php:1381
$dir
$dir
Definition: Autoload.php:8
Installer\findExtensions
findExtensions( $directory='extensions')
Finds extensions that follow the format /$directory/Name/Name.php, and returns an array containing th...
Definition: Installer.php:1344
Http\get
static get( $url, $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'GET' )
Definition: Http.php:98
$command
$command
Definition: cdb.php:64
Installer\getInstallerConfig
static getInstallerConfig(Config $baseConfig)
Constructs a Config object that contains configuration settings that should be overwritten for the in...
Definition: Installer.php:361
$line
$line
Definition: cdb.php:58
$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
$value
$value
Definition: styleTest.css.php:45
Installer\$envPreps
array $envPreps
A list of environment preparation methods called by doEnvironmentPreps().
Definition: Installer.php:144
$wgExtensionDirectory
$wgExtensionDirectory
Filesystem extensions directory.
Definition: DefaultSettings.php:239
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:76
Installer\$installSteps
array $installSteps
The actual list of installation steps.
Definition: Installer.php:230
wfIsWindows
wfIsWindows()
Check if the operating system is Windows.
Definition: GlobalFunctions.php:2033
wfEscapeShellArg
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
Definition: GlobalFunctions.php:2195
Installer\doEnvironmentPreps
doEnvironmentPreps()
Definition: Installer.php:504
CACHE_ANYTHING
const CACHE_ANYTHING
Definition: Defines.php:99
Installer\getDBInstaller
getDBInstaller( $type=false)
Get an instance of DatabaseInstaller for the specified DB type.
Definition: Installer.php:554
DatabaseInstaller
Base class for DBMS-specific installation helper classes.
Definition: DatabaseInstaller.php:33
$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:1956
Installer\envCheckDB
envCheckDB()
Environment check for DB types.
Definition: Installer.php:740
Installer\getInstallSteps
getInstallSteps(DatabaseInstaller $installer)
Get an array of install steps.
Definition: Installer.php:1455
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:468
Installer\$compiledDBs
array $compiledDBs
List of detected DBs, access using getCompiledDBs().
Definition: Installer.php:63
wfIniGetBool
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
Definition: GlobalFunctions.php:2176
Installer\doEnvironmentChecks
doEnvironmentChecks()
Do initial checks of the PHP environment.
Definition: Installer.php:475
EDIT_NEW
const EDIT_NEW
Definition: Defines.php:150
Installer\envCheckGraphics
envCheckGraphics()
Environment check for ImageMagick and GD.
Definition: Installer.php:902
wfShorthandToInteger
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
Definition: GlobalFunctions.php:3339
Installer\apacheModulePresent
static apacheModulePresent( $moduleName)
Checks for presence of an Apache module.
Definition: Installer.php:1304
PhpXmlBugTester
Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
Definition: PhpBugTests.php:30
Title
Represents a title within MediaWiki.
Definition: Title.php:39
Installer\envCheckPCRE
envCheckPCRE()
Environment check for the PCRE module.
Definition: Installer.php:798
$ext
$ext
Definition: NoLocalSettings.php:25
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
Installer\getParserOptions
getParserOptions()
Definition: Installer.php:693
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:167
$path
$path
Definition: NoLocalSettings.php:26
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
Installer\$licenses
array $licenses
License types.
Definition: Installer.php:281
Installer\disableTimeLimit
disableTimeLimit()
Disable the time limit for execution.
Definition: Installer.php:1748
$keys
$keys
Definition: testCompression.php:65
$source
$source
Definition: mwdoc-filter.php:45
Installer\envCheckServer
envCheckServer()
Environment check to inform user which server we've assumed.
Definition: Installer.php:950
Installer
Base installer class.
Definition: Installer.php:43
Installer\MINIMUM_PCRE_VERSION
const MINIMUM_PCRE_VERSION
The oldest version of PCRE we can support.
Definition: Installer.php:51
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:183
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
Installer\getDBTypes
static getDBTypes()
Get a list of known DB types.
Definition: Installer.php:458
Installer\disableLinkPopups
disableLinkPopups()
Definition: Installer.php:697
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:23
Installer\$mediaWikiAnnounceUrl
$mediaWikiAnnounceUrl
URL to mediawiki-announce subscription.
Definition: Installer.php:318
wfIsHHVM
wfIsHHVM()
Check if we are running under HHVM.
Definition: GlobalFunctions.php:2046
Installer\includeExtensions
includeExtensions()
Installs the auto-detected extensions.
Definition: Installer.php:1395
$wgStyleDirectory
$wgStyleDirectory
Filesystem stylesheets directory.
Definition: DefaultSettings.php:246
Installer\envCheckGit
envCheckGit()
Search for git.
Definition: Installer.php:928
Installer\getDocUrl
getDocUrl( $page)
Overridden by WebInstaller to provide lastPage parameters.
Definition: Installer.php:1331
Installer\subscribeToMediaWikiAnnounce
subscribeToMediaWikiAnnounce(Status $s)
Definition: Installer.php:1628
Installer\unicodeChar
unicodeChar( $c)
Convert a hex string representing a Unicode code point to that code point.
Definition: Installer.php:1088
CACHE_DB
const CACHE_DB
Definition: Defines.php:101
array
the array() calling protocol came about after MediaWiki 1.4rc1.
Installer\maybeGetWebserverPrimaryGroup
static maybeGetWebserverPrimaryGroup()
On POSIX systems return the primary group of the webserver we're running under.
Definition: Installer.php:643
Installer\$defaultVarNames
array $defaultVarNames
MediaWiki configuration globals that will eventually be passed through to LocalSettings....
Definition: Installer.php:156
wfShellExec
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
Definition: GlobalFunctions.php:2297
$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:783
Installer\$envChecks
array $envChecks
A list of environment check methods called by doEnvironmentChecks().
Definition: Installer.php:121
Installer\envCheckModSecurity
envCheckModSecurity()
Scare user to death if they have mod_security or mod_security2.
Definition: Installer.php:869
Installer\locateExecutable
static locateExecutable( $path, $names, $versionInfo=false)
Search a path for any of the given executable names.
Definition: Installer.php:1199