MediaWiki  master
Installer.php
Go to the documentation of this file.
1 <?php
30 
52 abstract class Installer {
53 
60  const MINIMUM_PCRE_VERSION = '7.2';
61 
65  protected $settings;
66 
72  protected $compiledDBs;
73 
79  protected $dbInstallers = [];
80 
86  protected $minMemorySize = 50;
87 
93  protected $parserTitle;
94 
100  protected $parserOptions;
101 
111  protected static $dbTypes = [
112  'mysql',
113  'postgres',
114  'sqlite',
115  ];
116 
128  protected $envChecks = [
129  'envCheckDB',
130  'envCheckPCRE',
131  'envCheckMemory',
132  'envCheckCache',
133  'envCheckModSecurity',
134  'envCheckDiff3',
135  'envCheckGraphics',
136  'envCheckGit',
137  'envCheckServer',
138  'envCheckPath',
139  'envCheckShellLocale',
140  'envCheckUploadsDirectory',
141  'envCheckLibicu',
142  'envCheckSuhosinMaxValueLength',
143  'envCheck64Bit',
144  ];
145 
151  protected $envPreps = [
152  'envPrepServer',
153  'envPrepPath',
154  ];
155 
163  protected $defaultVarNames = [
164  'wgSitename',
165  'wgPasswordSender',
166  'wgLanguageCode',
167  'wgRightsIcon',
168  'wgRightsText',
169  'wgRightsUrl',
170  'wgEnableEmail',
171  'wgEnableUserEmail',
172  'wgEnotifUserTalk',
173  'wgEnotifWatchlist',
174  'wgEmailAuthentication',
175  'wgDBname',
176  'wgDBtype',
177  'wgDiff3',
178  'wgImageMagickConvertCommand',
179  'wgGitBin',
180  'IP',
181  'wgScriptPath',
182  'wgMetaNamespace',
183  'wgDeletedDirectory',
184  'wgEnableUploads',
185  'wgShellLocale',
186  'wgSecretKey',
187  'wgUseInstantCommons',
188  'wgUpgradeKey',
189  'wgDefaultSkin',
190  'wgPingback',
191  ];
192 
200  protected $internalDefaults = [
201  '_UserLang' => 'en',
202  '_Environment' => false,
203  '_RaiseMemory' => false,
204  '_UpgradeDone' => false,
205  '_InstallDone' => false,
206  '_Caches' => [],
207  '_InstallPassword' => '',
208  '_SameAccount' => true,
209  '_CreateDBAccount' => false,
210  '_NamespaceType' => 'site-name',
211  '_AdminName' => '', // will be set later, when the user selects language
212  '_AdminPassword' => '',
213  '_AdminPasswordConfirm' => '',
214  '_AdminEmail' => '',
215  '_Subscribe' => false,
216  '_SkipOptional' => 'continue',
217  '_RightsProfile' => 'wiki',
218  '_LicenseCode' => 'none',
219  '_CCDone' => false,
220  '_Extensions' => [],
221  '_Skins' => [],
222  '_MemCachedServers' => '',
223  '_UpgradeKeySupplied' => false,
224  '_ExistingDBSettings' => false,
225 
226  // $wgLogo is probably wrong (T50084); set something that will work.
227  // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
228  'wgLogo' => '$wgResourceBasePath/resources/assets/wiki.png',
229  'wgAuthenticationTokenVersion' => 1,
230  ];
231 
238  private $installSteps = [];
239 
245  protected $extraInstallSteps = [];
246 
252  protected $objectCaches = [
253  'apc' => 'apc_fetch',
254  'apcu' => 'apcu_fetch',
255  'wincache' => 'wincache_ucache_get'
256  ];
257 
263  public $rightsProfiles = [
264  'wiki' => [],
265  'no-anon' => [
266  '*' => [ 'edit' => false ]
267  ],
268  'fishbowl' => [
269  '*' => [
270  'createaccount' => false,
271  'edit' => false,
272  ],
273  ],
274  'private' => [
275  '*' => [
276  'createaccount' => false,
277  'edit' => false,
278  'read' => false,
279  ],
280  ],
281  ];
282 
288  public $licenses = [
289  'cc-by' => [
290  'url' => 'https://creativecommons.org/licenses/by/4.0/',
291  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by.png',
292  ],
293  'cc-by-sa' => [
294  'url' => 'https://creativecommons.org/licenses/by-sa/4.0/',
295  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
296  ],
297  'cc-by-nc-sa' => [
298  'url' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
299  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
300  ],
301  'cc-0' => [
302  'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
303  'icon' => '$wgResourceBasePath/resources/assets/licenses/cc-0.png',
304  ],
305  'gfdl' => [
306  'url' => 'https://www.gnu.org/copyleft/fdl.html',
307  'icon' => '$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
308  ],
309  'none' => [
310  'url' => '',
311  'icon' => '',
312  'text' => ''
313  ],
314  'cc-choose' => [
315  // Details will be filled in by the selector.
316  'url' => '',
317  'icon' => '',
318  'text' => '',
319  ],
320  ];
321 
326  'https://lists.wikimedia.org/mailman/subscribe/mediawiki-announce';
327 
332  'ca', 'cs', 'da', 'de', 'en', 'es', 'et', 'eu', 'fi', 'fr', 'hr', 'hu',
333  'it', 'ja', 'ko', 'lt', 'nl', 'no', 'pl', 'pt', 'pt-br', 'ro', 'ru',
334  'sl', 'sr', 'sv', 'tr', 'uk'
335  ];
336 
345  abstract public function showMessage( $msg, ...$params );
346 
352  abstract public function showError( $msg, ...$params );
353 
358  abstract public function showStatusMessage( Status $status );
359 
370  public static function getInstallerConfig( Config $baseConfig ) {
371  $configOverrides = new HashConfig();
372 
373  // disable (problematic) object cache types explicitly, preserving all other (working) ones
374  // bug T113843
375  $emptyCache = [ 'class' => EmptyBagOStuff::class ];
376 
377  $objectCaches = [
378  CACHE_NONE => $emptyCache,
379  CACHE_DB => $emptyCache,
380  CACHE_ANYTHING => $emptyCache,
381  CACHE_MEMCACHED => $emptyCache,
382  ] + $baseConfig->get( 'ObjectCaches' );
383 
384  $configOverrides->set( 'ObjectCaches', $objectCaches );
385 
386  // Load the installer's i18n.
387  $messageDirs = $baseConfig->get( 'MessagesDirs' );
388  $messageDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
389 
390  $configOverrides->set( 'MessagesDirs', $messageDirs );
391 
392  $installerConfig = new MultiConfig( [ $configOverrides, $baseConfig ] );
393 
394  // make sure we use the installer config as the main config
395  $configRegistry = $baseConfig->get( 'ConfigRegistry' );
396  $configRegistry['main'] = function () use ( $installerConfig ) {
397  return $installerConfig;
398  };
399 
400  $configOverrides->set( 'ConfigRegistry', $configRegistry );
401 
402  return $installerConfig;
403  }
404 
408  public function __construct() {
409  global $wgMemc, $wgUser, $wgObjectCaches;
410 
411  $defaultConfig = new GlobalVarConfig(); // all the stuff from DefaultSettings.php
412  $installerConfig = self::getInstallerConfig( $defaultConfig );
413 
414  // Reset all services and inject config overrides
415  MediaWikiServices::resetGlobalInstance( $installerConfig );
416 
417  // Don't attempt to load user language options (T126177)
418  // This will be overridden in the web installer with the user-specified language
419  RequestContext::getMain()->setLanguage( 'en' );
420 
421  // Disable all global services, since we don't have any configuration yet!
422  MediaWikiServices::disableStorageBackend();
423 
424  $mwServices = MediaWikiServices::getInstance();
425 
426  // Disable i18n cache
427  $mwServices->getLocalisationCache()->disableBackend();
428 
429  // Clear language cache so the old i18n cache doesn't sneak back in
431 
432  // Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
433  // SqlBagOStuff will then throw since we just disabled wfGetDB)
434  $wgObjectCaches = $mwServices->getMainConfig()->get( 'ObjectCaches' );
436 
437  // Disable interwiki lookup, to avoid database access during parses
438  $mwServices->redefineService( 'InterwikiLookup', function () {
439  return new NullInterwikiLookup();
440  } );
441 
442  // Having a user with id = 0 safeguards us from DB access via User::loadOptions().
443  $wgUser = User::newFromId( 0 );
444  RequestContext::getMain()->setUser( $wgUser );
445 
446  $this->settings = $this->internalDefaults;
447 
448  foreach ( $this->defaultVarNames as $var ) {
449  $this->settings[$var] = $GLOBALS[$var];
450  }
451 
452  $this->doEnvironmentPreps();
453 
454  $this->compiledDBs = [];
455  foreach ( self::getDBTypes() as $type ) {
456  $installer = $this->getDBInstaller( $type );
457 
458  if ( !$installer->isCompiled() ) {
459  continue;
460  }
461  $this->compiledDBs[] = $type;
462  }
463 
464  $this->parserTitle = Title::newFromText( 'Installer' );
465  $this->parserOptions = new ParserOptions( $wgUser ); // language will be wrong :(
466  $this->parserOptions->setTidy( true );
467  // Don't try to access DB before user language is initialised
468  $this->setParserLanguage( $mwServices->getLanguageFactory()->getLanguage( 'en' ) );
469  }
470 
476  public static function getDBTypes() {
477  return self::$dbTypes;
478  }
479 
493  public function doEnvironmentChecks() {
494  // PHP version has already been checked by entry scripts
495  // Show message here for information purposes
496  $this->showMessage( 'config-env-php', PHP_VERSION );
497 
498  $good = true;
499  // Must go here because an old version of PCRE can prevent other checks from completing
500  $pcreVersion = explode( ' ', PCRE_VERSION, 2 )[0];
501  if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
502  $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
503  $good = false;
504  } else {
505  foreach ( $this->envChecks as $check ) {
506  $status = $this->$check();
507  if ( $status === false ) {
508  $good = false;
509  }
510  }
511  }
512 
513  $this->setVar( '_Environment', $good );
514 
515  return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
516  }
517 
518  public function doEnvironmentPreps() {
519  foreach ( $this->envPreps as $prep ) {
520  $this->$prep();
521  }
522  }
523 
530  public function setVar( $name, $value ) {
531  $this->settings[$name] = $value;
532  }
533 
544  public function getVar( $name, $default = null ) {
545  return $this->settings[$name] ?? $default;
546  }
547 
553  public function getCompiledDBs() {
554  return $this->compiledDBs;
555  }
556 
564  public static function getDBInstallerClass( $type ) {
565  return ucfirst( $type ) . 'Installer';
566  }
567 
575  public function getDBInstaller( $type = false ) {
576  if ( !$type ) {
577  $type = $this->getVar( 'wgDBtype' );
578  }
579 
580  $type = strtolower( $type );
581 
582  if ( !isset( $this->dbInstallers[$type] ) ) {
583  $class = self::getDBInstallerClass( $type );
584  $this->dbInstallers[$type] = new $class( $this );
585  }
586 
587  return $this->dbInstallers[$type];
588  }
589 
595  public static function getExistingLocalSettings() {
596  global $IP;
597 
598  // You might be wondering why this is here. Well if you don't do this
599  // then some poorly-formed extensions try to call their own classes
600  // after immediately registering them. We really need to get extension
601  // registration out of the global scope and into a real format.
602  // @see https://phabricator.wikimedia.org/T69440
603  global $wgAutoloadClasses;
604  $wgAutoloadClasses = [];
605 
606  // LocalSettings.php should not call functions, except wfLoadSkin/wfLoadExtensions
607  // Define the required globals here, to ensure, the functions can do it work correctly.
608  // phpcs:ignore MediaWiki.VariableAnalysis.UnusedGlobalVariables
610 
611  Wikimedia\suppressWarnings();
612  $_lsExists = file_exists( "$IP/LocalSettings.php" );
613  Wikimedia\restoreWarnings();
614 
615  if ( !$_lsExists ) {
616  return false;
617  }
618  unset( $_lsExists );
619 
620  require "$IP/includes/DefaultSettings.php";
621  require "$IP/LocalSettings.php";
622 
623  return get_defined_vars();
624  }
625 
635  public function getFakePassword( $realPassword ) {
636  return str_repeat( '*', strlen( $realPassword ) );
637  }
638 
646  public function setPassword( $name, $value ) {
647  if ( !preg_match( '/^\*+$/', $value ) ) {
648  $this->setVar( $name, $value );
649  }
650  }
651 
663  public static function maybeGetWebserverPrimaryGroup() {
664  if ( !function_exists( 'posix_getegid' ) || !function_exists( 'posix_getpwuid' ) ) {
665  # I don't know this, this isn't UNIX.
666  return null;
667  }
668 
669  # posix_getegid() *not* getmygid() because we want the group of the webserver,
670  # not whoever owns the current script.
671  $gid = posix_getegid();
672  $group = posix_getpwuid( $gid )['name'];
673 
674  return $group;
675  }
676 
693  public function parse( $text, $lineStart = false ) {
694  $parser = MediaWikiServices::getInstance()->getParser();
695 
696  try {
697  $out = $parser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
698  $html = $out->getText( [
699  'enableSectionEditLinks' => false,
700  'unwrap' => true,
701  ] );
702  $html = Parser::stripOuterParagraph( $html );
703  } catch ( Wikimedia\Services\ServiceDisabledException $e ) {
704  $html = '<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
705  }
706 
707  return $html;
708  }
709 
713  public function getParserOptions() {
714  return $this->parserOptions;
715  }
716 
717  public function disableLinkPopups() {
718  $this->parserOptions->setExternalLinkTarget( false );
719  }
720 
721  public function restoreLinkPopups() {
722  global $wgExternalLinkTarget;
723  $this->parserOptions->setExternalLinkTarget( $wgExternalLinkTarget );
724  }
725 
734  public function populateSiteStats( DatabaseInstaller $installer ) {
735  $status = $installer->getConnection();
736  if ( !$status->isOK() ) {
737  return $status;
738  }
739  // @phan-suppress-next-line PhanUndeclaredMethod
740  $status->value->insert(
741  'site_stats',
742  [
743  'ss_row_id' => 1,
744  'ss_total_edits' => 0,
745  'ss_good_articles' => 0,
746  'ss_total_pages' => 0,
747  'ss_users' => 0,
748  'ss_active_users' => 0,
749  'ss_images' => 0
750  ],
751  __METHOD__, 'IGNORE'
752  );
753 
754  return Status::newGood();
755  }
756 
761  protected function envCheckDB() {
762  global $wgLang;
764  $dbType = $this->getVar( 'wgDBtype' );
765 
766  $allNames = [];
767 
768  // Messages: config-type-mysql, config-type-postgres, config-type-sqlite
769  foreach ( self::getDBTypes() as $name ) {
770  $allNames[] = wfMessage( "config-type-$name" )->text();
771  }
772 
773  $databases = $this->getCompiledDBs();
774 
775  $databases = array_flip( $databases );
776  $ok = true;
777  foreach ( array_keys( $databases ) as $db ) {
778  $installer = $this->getDBInstaller( $db );
779  $status = $installer->checkPrerequisites();
780  if ( !$status->isGood() ) {
781  if ( !$this instanceof WebInstaller && $db === $dbType ) {
782  // Strictly check the key database type instead of just outputting message
783  // Note: No perform this check run from the web installer, since this method always called by
784  // the welcome page under web installation, so $dbType will always be 'mysql'
785  $ok = false;
786  }
787  $this->showStatusMessage( $status );
788  unset( $databases[$db] );
789  }
790  }
791  $databases = array_flip( $databases );
792  if ( !$databases ) {
793  $this->showError( 'config-no-db', $wgLang->commaList( $allNames ), count( $allNames ) );
794  return false;
795  }
796  return $ok;
797  }
798 
807  protected function envCheckPCRE() {
808  Wikimedia\suppressWarnings();
809  $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' );
810  // Need to check for \p support too, as PCRE can be compiled
811  // with utf8 support, but not unicode property support.
812  // check that \p{Zs} (space separators) matches
813  // U+3000 (Ideographic space)
814  $regexprop = preg_replace( '/\p{Zs}/u', '', "-\u{3000}-" );
815  Wikimedia\restoreWarnings();
816  if ( $regexd != '--' || $regexprop != '--' ) {
817  $this->showError( 'config-pcre-no-utf8' );
818 
819  return false;
820  }
821 
822  return true;
823  }
824 
829  protected function envCheckMemory() {
830  $limit = ini_get( 'memory_limit' );
831 
832  if ( !$limit || $limit == -1 ) {
833  return true;
834  }
835 
836  $n = wfShorthandToInteger( $limit );
837 
838  if ( $n < $this->minMemorySize * 1024 * 1024 ) {
839  $newLimit = "{$this->minMemorySize}M";
840 
841  if ( ini_set( "memory_limit", $newLimit ) === false ) {
842  $this->showMessage( 'config-memory-bad', $limit );
843  } else {
844  $this->showMessage( 'config-memory-raised', $limit, $newLimit );
845  $this->setVar( '_RaiseMemory', true );
846  }
847  }
848 
849  return true;
850  }
851 
855  protected function envCheckCache() {
856  $caches = [];
857  foreach ( $this->objectCaches as $name => $function ) {
858  if ( function_exists( $function ) ) {
859  $caches[$name] = true;
860  }
861  }
862 
863  if ( !$caches ) {
864  $this->showMessage( 'config-no-cache-apcu' );
865  }
866 
867  $this->setVar( '_Caches', $caches );
868  }
869 
874  protected function envCheckModSecurity() {
875  if ( self::apacheModulePresent( 'mod_security' )
876  || self::apacheModulePresent( 'mod_security2' ) ) {
877  $this->showMessage( 'config-mod-security' );
878  }
879 
880  return true;
881  }
882 
887  protected function envCheckDiff3() {
888  $names = [ "gdiff3", "diff3" ];
889  if ( wfIsWindows() ) {
890  $names[] = 'diff3.exe';
891  }
892  $versionInfo = [ '--version', 'GNU diffutils' ];
893 
894  $diff3 = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
895 
896  if ( $diff3 ) {
897  $this->setVar( 'wgDiff3', $diff3 );
898  } else {
899  $this->setVar( 'wgDiff3', false );
900  $this->showMessage( 'config-diff3-bad' );
901  }
902 
903  return true;
904  }
905 
910  protected function envCheckGraphics() {
911  $names = wfIsWindows() ? 'convert.exe' : 'convert';
912  $versionInfo = [ '-version', 'ImageMagick' ];
913  $convert = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
914 
915  $this->setVar( 'wgImageMagickConvertCommand', '' );
916  if ( $convert ) {
917  $this->setVar( 'wgImageMagickConvertCommand', $convert );
918  $this->showMessage( 'config-imagemagick', $convert );
919 
920  return true;
921  } elseif ( function_exists( 'imagejpeg' ) ) {
922  $this->showMessage( 'config-gd' );
923  } else {
924  $this->showMessage( 'config-no-scaling' );
925  }
926 
927  return true;
928  }
929 
936  protected function envCheckGit() {
937  $names = wfIsWindows() ? 'git.exe' : 'git';
938  $versionInfo = [ '--version', 'git version' ];
939 
940  $git = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
941 
942  if ( $git ) {
943  $this->setVar( 'wgGitBin', $git );
944  $this->showMessage( 'config-git', $git );
945  } else {
946  $this->setVar( 'wgGitBin', false );
947  $this->showMessage( 'config-git-bad' );
948  }
949 
950  return true;
951  }
952 
958  protected function envCheckServer() {
959  $server = $this->envGetDefaultServer();
960  if ( $server !== null ) {
961  $this->showMessage( 'config-using-server', $server );
962  }
963  return true;
964  }
965 
971  protected function envCheckPath() {
972  $this->showMessage(
973  'config-using-uri',
974  $this->getVar( 'wgServer' ),
975  $this->getVar( 'wgScriptPath' )
976  );
977  return true;
978  }
979 
984  protected function envCheckShellLocale() {
985  $os = php_uname( 's' );
986  $supported = [ 'Linux', 'SunOS', 'HP-UX', 'Darwin' ]; # Tested these
987 
988  if ( !in_array( $os, $supported ) ) {
989  return true;
990  }
991 
992  if ( Shell::isDisabled() ) {
993  return true;
994  }
995 
996  # Get a list of available locales.
997  $result = Shell::command( '/usr/bin/locale', '-a' )
998  ->execute();
999 
1000  if ( $result->getExitCode() != 0 ) {
1001  return true;
1002  }
1003 
1004  $lines = $result->getStdout();
1005  $lines = array_map( 'trim', explode( "\n", $lines ) );
1006  $candidatesByLocale = [];
1007  $candidatesByLang = [];
1008  foreach ( $lines as $line ) {
1009  if ( $line === '' ) {
1010  continue;
1011  }
1012 
1013  if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
1014  continue;
1015  }
1016 
1017  list( , $lang, , , ) = $m;
1018 
1019  $candidatesByLocale[$m[0]] = $m;
1020  $candidatesByLang[$lang][] = $m;
1021  }
1022 
1023  # Try the current value of LANG.
1024  if ( isset( $candidatesByLocale[getenv( 'LANG' )] ) ) {
1025  $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
1026 
1027  return true;
1028  }
1029 
1030  # Try the most common ones.
1031  $commonLocales = [ 'C.UTF-8', 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' ];
1032  foreach ( $commonLocales as $commonLocale ) {
1033  if ( isset( $candidatesByLocale[$commonLocale] ) ) {
1034  $this->setVar( 'wgShellLocale', $commonLocale );
1035 
1036  return true;
1037  }
1038  }
1039 
1040  # Is there an available locale in the Wiki's language?
1041  $wikiLang = $this->getVar( 'wgLanguageCode' );
1042 
1043  if ( isset( $candidatesByLang[$wikiLang] ) ) {
1044  $m = reset( $candidatesByLang[$wikiLang] );
1045  $this->setVar( 'wgShellLocale', $m[0] );
1046 
1047  return true;
1048  }
1049 
1050  # Are there any at all?
1051  if ( count( $candidatesByLocale ) ) {
1052  $m = reset( $candidatesByLocale );
1053  $this->setVar( 'wgShellLocale', $m[0] );
1054 
1055  return true;
1056  }
1057 
1058  # Give up.
1059  return true;
1060  }
1061 
1066  protected function envCheckUploadsDirectory() {
1067  global $IP;
1068 
1069  $dir = $IP . '/images/';
1070  $url = $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/images/';
1071  $safe = !$this->dirIsExecutable( $dir, $url );
1072 
1073  if ( !$safe ) {
1074  $this->showMessage( 'config-uploads-not-safe', $dir );
1075  }
1076 
1077  return true;
1078  }
1079 
1085  protected function envCheckSuhosinMaxValueLength() {
1086  $currentValue = ini_get( 'suhosin.get.max_value_length' );
1087  $minRequired = 2000;
1088  $recommended = 5000;
1089  if ( $currentValue > 0 && $currentValue < $minRequired ) {
1090  $this->showError( 'config-suhosin-max-value-length', $currentValue, $minRequired, $recommended );
1091  return false;
1092  }
1093 
1094  return true;
1095  }
1096 
1103  protected function envCheck64Bit() {
1104  if ( PHP_INT_SIZE == 4 ) {
1105  $this->showMessage( 'config-using-32bit' );
1106  }
1107 
1108  return true;
1109  }
1110 
1114  protected function envCheckLibicu() {
1122  $not_normal_c = "\u{FA6C}";
1123  $normal_c = "\u{242EE}";
1124 
1125  $useNormalizer = 'php';
1126  $needsUpdate = false;
1127 
1128  if ( function_exists( 'normalizer_normalize' ) ) {
1129  $useNormalizer = 'intl';
1130  $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
1131  if ( $intl !== $normal_c ) {
1132  $needsUpdate = true;
1133  }
1134  }
1135 
1136  // Uses messages 'config-unicode-using-php' and 'config-unicode-using-intl'
1137  if ( $useNormalizer === 'php' ) {
1138  $this->showMessage( 'config-unicode-pure-php-warning' );
1139  } else {
1140  $this->showMessage( 'config-unicode-using-' . $useNormalizer );
1141  if ( $needsUpdate ) {
1142  $this->showMessage( 'config-unicode-update-warning' );
1143  }
1144  }
1145  }
1146 
1150  protected function envPrepServer() {
1151  $server = $this->envGetDefaultServer();
1152  if ( $server !== null ) {
1153  $this->setVar( 'wgServer', $server );
1154  }
1155  }
1156 
1161  abstract protected function envGetDefaultServer();
1162 
1166  protected function envPrepPath() {
1167  global $IP;
1168  $IP = dirname( dirname( __DIR__ ) );
1169  $this->setVar( 'IP', $IP );
1170  }
1171 
1180  public function dirIsExecutable( $dir, $url ) {
1181  $scriptTypes = [
1182  'php' => [
1183  "<?php echo 'exec';",
1184  "#!/var/env php\n<?php echo 'exec';",
1185  ],
1186  ];
1187 
1188  // it would be good to check other popular languages here, but it'll be slow.
1189 
1190  Wikimedia\suppressWarnings();
1191 
1192  foreach ( $scriptTypes as $ext => $contents ) {
1193  foreach ( $contents as $source ) {
1194  $file = 'exectest.' . $ext;
1195 
1196  if ( !file_put_contents( $dir . $file, $source ) ) {
1197  break;
1198  }
1199 
1200  try {
1201  $text = MediaWikiServices::getInstance()->getHttpRequestFactory()->
1202  get( $url . $file, [ 'timeout' => 3 ], __METHOD__ );
1203  } catch ( Exception $e ) {
1204  // HttpRequestFactory::get can throw with allow_url_fopen = false and no curl
1205  // extension.
1206  $text = null;
1207  }
1208  unlink( $dir . $file );
1209 
1210  if ( $text == 'exec' ) {
1211  Wikimedia\restoreWarnings();
1212 
1213  return $ext;
1214  }
1215  }
1216  }
1217 
1218  Wikimedia\restoreWarnings();
1219 
1220  return false;
1221  }
1222 
1229  public static function apacheModulePresent( $moduleName ) {
1230  if ( function_exists( 'apache_get_modules' ) && in_array( $moduleName, apache_get_modules() ) ) {
1231  return true;
1232  }
1233  // try it the hard way
1234  ob_start();
1235  phpinfo( INFO_MODULES );
1236  $info = ob_get_clean();
1237 
1238  return strpos( $info, $moduleName ) !== false;
1239  }
1240 
1246  public function setParserLanguage( $lang ) {
1247  $this->parserOptions->setTargetLanguage( $lang );
1248  $this->parserOptions->setUserLang( $lang );
1249  }
1250 
1256  protected function getDocUrl( $page ) {
1257  return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1258  }
1259 
1269  public function findExtensions( $directory = 'extensions' ) {
1270  switch ( $directory ) {
1271  case 'extensions':
1272  return $this->findExtensionsByType( 'extension', 'extensions' );
1273  case 'skins':
1274  return $this->findExtensionsByType( 'skin', 'skins' );
1275  default:
1276  throw new InvalidArgumentException( "Invalid extension type" );
1277  }
1278  }
1279 
1289  protected function findExtensionsByType( $type = 'extension', $directory = 'extensions' ) {
1290  if ( $this->getVar( 'IP' ) === null ) {
1291  return Status::newGood( [] );
1292  }
1293 
1294  $extDir = $this->getVar( 'IP' ) . '/' . $directory;
1295  if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
1296  return Status::newGood( [] );
1297  }
1298 
1299  $dh = opendir( $extDir );
1300  $exts = [];
1301  $status = new Status;
1302  while ( ( $file = readdir( $dh ) ) !== false ) {
1303  // skip non-dirs and hidden directories
1304  if ( !is_dir( "$extDir/$file" ) || $file[0] === '.' ) {
1305  continue;
1306  }
1307  $extStatus = $this->getExtensionInfo( $type, $directory, $file );
1308  if ( $extStatus->isOK() ) {
1309  $exts[$file] = $extStatus->value;
1310  } elseif ( $extStatus->hasMessage( 'config-extension-not-found' ) ) {
1311  // (T225512) The directory is not actually an extension. Downgrade to warning.
1312  $status->warning( 'config-extension-not-found', $file );
1313  } else {
1314  $status->merge( $extStatus );
1315  }
1316  }
1317  closedir( $dh );
1318  uksort( $exts, 'strnatcasecmp' );
1319 
1320  $status->value = $exts;
1321 
1322  return $status;
1323  }
1324 
1332  protected function getExtensionInfo( $type, $parentRelPath, $name ) {
1333  if ( $this->getVar( 'IP' ) === null ) {
1334  throw new Exception( 'Cannot find extensions since the IP variable is not yet set' );
1335  }
1336  if ( $type !== 'extension' && $type !== 'skin' ) {
1337  throw new InvalidArgumentException( "Invalid extension type" );
1338  }
1339  $absDir = $this->getVar( 'IP' ) . "/$parentRelPath/$name";
1340  $relDir = "../$parentRelPath/$name";
1341  if ( !is_dir( $absDir ) ) {
1342  return Status::newFatal( 'config-extension-not-found', $name );
1343  }
1344  $jsonFile = $type . '.json';
1345  $fullJsonFile = "$absDir/$jsonFile";
1346  $isJson = file_exists( $fullJsonFile );
1347  $isPhp = false;
1348  if ( !$isJson ) {
1349  // Only fallback to PHP file if JSON doesn't exist
1350  $fullPhpFile = "$absDir/$name.php";
1351  $isPhp = file_exists( $fullPhpFile );
1352  }
1353  if ( !$isJson && !$isPhp ) {
1354  return Status::newFatal( 'config-extension-not-found', $name );
1355  }
1356 
1357  // Extension exists. Now see if there are screenshots
1358  $info = [];
1359  if ( is_dir( "$absDir/screenshots" ) ) {
1360  $paths = glob( "$absDir/screenshots/*.png" );
1361  foreach ( $paths as $path ) {
1362  $info['screenshots'][] = str_replace( $absDir, $relDir, $path );
1363  }
1364  }
1365 
1366  if ( $isJson ) {
1367  $jsonStatus = $this->readExtension( $fullJsonFile );
1368  if ( !$jsonStatus->isOK() ) {
1369  return $jsonStatus;
1370  }
1371  $info += $jsonStatus->value;
1372  }
1373 
1374  return Status::newGood( $info );
1375  }
1376 
1385  private function readExtension( $fullJsonFile, $extDeps = [], $skinDeps = [] ) {
1386  $load = [
1387  $fullJsonFile => 1
1388  ];
1389  if ( $extDeps ) {
1390  $extDir = $this->getVar( 'IP' ) . '/extensions';
1391  foreach ( $extDeps as $dep ) {
1392  $fname = "$extDir/$dep/extension.json";
1393  if ( !file_exists( $fname ) ) {
1394  return Status::newFatal( 'config-extension-not-found', $dep );
1395  }
1396  $load[$fname] = 1;
1397  }
1398  }
1399  if ( $skinDeps ) {
1400  $skinDir = $this->getVar( 'IP' ) . '/skins';
1401  foreach ( $skinDeps as $dep ) {
1402  $fname = "$skinDir/$dep/skin.json";
1403  if ( !file_exists( $fname ) ) {
1404  return Status::newFatal( 'config-extension-not-found', $dep );
1405  }
1406  $load[$fname] = 1;
1407  }
1408  }
1409  $registry = new ExtensionRegistry();
1410  try {
1411  $info = $registry->readFromQueue( $load );
1412  } catch ( ExtensionDependencyError $e ) {
1413  if ( $e->incompatibleCore || $e->incompatibleSkins
1414  || $e->incompatibleExtensions
1415  ) {
1416  // If something is incompatible with a dependency, we have no real
1417  // option besides skipping it
1418  return Status::newFatal( 'config-extension-dependency',
1419  basename( dirname( $fullJsonFile ) ), $e->getMessage() );
1420  } elseif ( $e->missingExtensions || $e->missingSkins ) {
1421  // There's an extension missing in the dependency tree,
1422  // so add those to the dependency list and try again
1423  $status = $this->readExtension(
1424  $fullJsonFile,
1425  array_merge( $extDeps, $e->missingExtensions ),
1426  array_merge( $skinDeps, $e->missingSkins )
1427  );
1428  if ( !$status->isOK() && !$status->hasMessage( 'config-extension-dependency' ) ) {
1429  $status = Status::newFatal( 'config-extension-dependency',
1430  basename( dirname( $fullJsonFile ) ), $status->getMessage() );
1431  }
1432  return $status;
1433  }
1434  // Some other kind of dependency error?
1435  return Status::newFatal( 'config-extension-dependency',
1436  basename( dirname( $fullJsonFile ) ), $e->getMessage() );
1437  }
1438  $ret = [];
1439  // The order of credits will be the order of $load,
1440  // so the first extension is the one we want to load,
1441  // everything else is a dependency
1442  $i = 0;
1443  foreach ( $info['credits'] as $name => $credit ) {
1444  $i++;
1445  if ( $i == 1 ) {
1446  // Extension we want to load
1447  continue;
1448  }
1449  $type = basename( $credit['path'] ) === 'skin.json' ? 'skins' : 'extensions';
1450  $ret['requires'][$type][] = $credit['name'];
1451  }
1452  $credits = array_values( $info['credits'] )[0];
1453  if ( isset( $credits['url'] ) ) {
1454  $ret['url'] = $credits['url'];
1455  }
1456  $ret['type'] = $credits['type'];
1457 
1458  return Status::newGood( $ret );
1459  }
1460 
1469  public function getDefaultSkin( array $skinNames ) {
1470  $defaultSkin = $GLOBALS['wgDefaultSkin'];
1471  if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) {
1472  return $defaultSkin;
1473  } else {
1474  return $skinNames[0];
1475  }
1476  }
1477 
1484  protected function includeExtensions() {
1485  global $IP;
1486  $exts = $this->getVar( '_Extensions' );
1487  $IP = $this->getVar( 'IP' );
1488 
1489  // Marker for DatabaseUpdater::loadExtensions so we don't
1490  // double load extensions
1491  define( 'MW_EXTENSIONS_LOADED', true );
1492 
1501  global $wgAutoloadClasses;
1502  $wgAutoloadClasses = [];
1503  $queue = [];
1504 
1505  require "$IP/includes/DefaultSettings.php";
1506 
1507  foreach ( $exts as $e ) {
1508  if ( file_exists( "$IP/extensions/$e/extension.json" ) ) {
1509  $queue["$IP/extensions/$e/extension.json"] = 1;
1510  } else {
1511  require_once "$IP/extensions/$e/$e.php";
1512  }
1513  }
1514 
1515  $registry = new ExtensionRegistry();
1516  $data = $registry->readFromQueue( $queue );
1517  $wgAutoloadClasses += $data['autoload'];
1518 
1519  // @phan-suppress-next-line PhanUndeclaredVariable $wgHooks is set by DefaultSettings
1520  $hooksWeWant = $wgHooks['LoadExtensionSchemaUpdates'] ?? [];
1521 
1522  if ( isset( $data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
1523  $hooksWeWant = array_merge_recursive(
1524  $hooksWeWant,
1525  $data['globals']['wgHooks']['LoadExtensionSchemaUpdates']
1526  );
1527  }
1528  // Unset everyone else's hooks. Lord knows what someone might be doing
1529  // in ParserFirstCallInit (see T29171)
1530  $GLOBALS['wgHooks'] = [ 'LoadExtensionSchemaUpdates' => $hooksWeWant ];
1531 
1532  return Status::newGood();
1533  }
1534 
1548  protected function getInstallSteps( DatabaseInstaller $installer ) {
1549  $coreInstallSteps = [
1550  [ 'name' => 'database', 'callback' => [ $installer, 'setupDatabase' ] ],
1551  [ 'name' => 'tables', 'callback' => [ $installer, 'createTables' ] ],
1552  [ 'name' => 'interwiki', 'callback' => [ $installer, 'populateInterwikiTable' ] ],
1553  [ 'name' => 'stats', 'callback' => [ $this, 'populateSiteStats' ] ],
1554  [ 'name' => 'keys', 'callback' => [ $this, 'generateKeys' ] ],
1555  [ 'name' => 'updates', 'callback' => [ $installer, 'insertUpdateKeys' ] ],
1556  [ 'name' => 'sysop', 'callback' => [ $this, 'createSysop' ] ],
1557  [ 'name' => 'mainpage', 'callback' => [ $this, 'createMainpage' ] ],
1558  ];
1559 
1560  // Build the array of install steps starting from the core install list,
1561  // then adding any callbacks that wanted to attach after a given step
1562  foreach ( $coreInstallSteps as $step ) {
1563  $this->installSteps[] = $step;
1564  if ( isset( $this->extraInstallSteps[$step['name']] ) ) {
1565  $this->installSteps = array_merge(
1566  $this->installSteps,
1567  $this->extraInstallSteps[$step['name']]
1568  );
1569  }
1570  }
1571 
1572  // Prepend any steps that want to be at the beginning
1573  if ( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
1574  $this->installSteps = array_merge(
1575  $this->extraInstallSteps['BEGINNING'],
1576  $this->installSteps
1577  );
1578  }
1579 
1580  // Extensions should always go first, chance to tie into hooks and such
1581  if ( count( $this->getVar( '_Extensions' ) ) ) {
1582  array_unshift( $this->installSteps,
1583  [ 'name' => 'extensions', 'callback' => [ $this, 'includeExtensions' ] ]
1584  );
1585  $this->installSteps[] = [
1586  'name' => 'extension-tables',
1587  'callback' => [ $installer, 'createExtensionTables' ]
1588  ];
1589  }
1590 
1591  return $this->installSteps;
1592  }
1593 
1602  public function performInstallation( $startCB, $endCB ) {
1603  $installResults = [];
1604  $installer = $this->getDBInstaller();
1605  $installer->preInstall();
1606  $steps = $this->getInstallSteps( $installer );
1607  foreach ( $steps as $stepObj ) {
1608  $name = $stepObj['name'];
1609  call_user_func_array( $startCB, [ $name ] );
1610 
1611  // Perform the callback step
1612  $status = call_user_func( $stepObj['callback'], $installer );
1613 
1614  // Output and save the results
1615  call_user_func( $endCB, $name, $status );
1616  $installResults[$name] = $status;
1617 
1618  // If we've hit some sort of fatal, we need to bail.
1619  // Callback already had a chance to do output above.
1620  if ( !$status->isOK() ) {
1621  break;
1622  }
1623  }
1624  if ( $status->isOK() ) {
1625  $this->showMessage(
1626  'config-install-db-success'
1627  );
1628  $this->setVar( '_InstallDone', true );
1629  }
1630 
1631  return $installResults;
1632  }
1633 
1639  public function generateKeys() {
1640  $keys = [ 'wgSecretKey' => 64 ];
1641  if ( strval( $this->getVar( 'wgUpgradeKey' ) ) === '' ) {
1642  $keys['wgUpgradeKey'] = 16;
1643  }
1644 
1645  return $this->doGenerateKeys( $keys );
1646  }
1647 
1654  protected function doGenerateKeys( $keys ) {
1655  $status = Status::newGood();
1656 
1657  foreach ( $keys as $name => $length ) {
1658  $secretKey = MWCryptRand::generateHex( $length );
1659  $this->setVar( $name, $secretKey );
1660  }
1661 
1662  return $status;
1663  }
1664 
1670  protected function createSysop() {
1671  $name = $this->getVar( '_AdminName' );
1672  $user = User::newFromName( $name );
1673 
1674  if ( !$user ) {
1675  // We should've validated this earlier anyway!
1676  return Status::newFatal( 'config-admin-error-user', $name );
1677  }
1678 
1679  if ( $user->idForName() == 0 ) {
1680  $user->addToDatabase();
1681 
1682  try {
1683  $user->setPassword( $this->getVar( '_AdminPassword' ) );
1684  } catch ( PasswordError $pwe ) {
1685  return Status::newFatal( 'config-admin-error-password', $name, $pwe->getMessage() );
1686  }
1687 
1688  $user->addGroup( 'sysop' );
1689  $user->addGroup( 'bureaucrat' );
1690  $user->addGroup( 'interface-admin' );
1691  if ( $this->getVar( '_AdminEmail' ) ) {
1692  $user->setEmail( $this->getVar( '_AdminEmail' ) );
1693  }
1694  $user->saveSettings();
1695 
1696  // Update user count
1697  $ssUpdate = SiteStatsUpdate::factory( [ 'users' => 1 ] );
1698  $ssUpdate->doUpdate();
1699  }
1700  $status = Status::newGood();
1701 
1702  if ( $this->getVar( '_Subscribe' ) && $this->getVar( '_AdminEmail' ) ) {
1703  $this->subscribeToMediaWikiAnnounce( $status );
1704  }
1705 
1706  return $status;
1707  }
1708 
1713  $params = [
1714  'email' => $this->getVar( '_AdminEmail' ),
1715  'language' => 'en',
1716  'digest' => 0
1717  ];
1718 
1719  // Mailman doesn't support as many languages as we do, so check to make
1720  // sure their selected language is available
1721  $myLang = $this->getVar( '_UserLang' );
1722  if ( in_array( $myLang, $this->mediaWikiAnnounceLanguages ) ) {
1723  $myLang = $myLang == 'pt-br' ? 'pt_BR' : $myLang; // rewrite to Mailman's pt_BR
1724  $params['language'] = $myLang;
1725  }
1726 
1728  $res = MWHttpRequest::factory( $this->mediaWikiAnnounceUrl,
1729  [ 'method' => 'POST', 'postData' => $params ], __METHOD__ )->execute();
1730  if ( !$res->isOK() ) {
1731  $s->warning( 'config-install-subscribe-fail', $res->getMessage() );
1732  }
1733  } else {
1734  $s->warning( 'config-install-subscribe-notpossible' );
1735  }
1736  }
1737 
1744  protected function createMainpage( DatabaseInstaller $installer ) {
1745  $status = Status::newGood();
1747  if ( $title->exists() ) {
1748  $status->warning( 'config-install-mainpage-exists' );
1749  return $status;
1750  }
1751  try {
1752  $page = WikiPage::factory( $title );
1753  $content = new WikitextContent(
1754  wfMessage( 'mainpagetext' )->inContentLanguage()->text() . "\n\n" .
1755  wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
1756  );
1757 
1758  $status = $page->doEditContent( $content,
1759  '',
1760  EDIT_NEW,
1761  false,
1762  User::newSystemUser( 'MediaWiki default' )
1763  );
1764  } catch ( Exception $e ) {
1765  // using raw, because $wgShowExceptionDetails can not be set yet
1766  $status->fatal( 'config-install-mainpage-failed', $e->getMessage() );
1767  }
1768 
1769  return $status;
1770  }
1771 
1775  public static function overrideConfig() {
1776  // Use PHP's built-in session handling, since MediaWiki's
1777  // SessionHandler can't work before we have an object cache set up.
1778  if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
1779  define( 'MW_NO_SESSION_HANDLER', 1 );
1780  }
1781 
1782  // Don't access the database
1783  $GLOBALS['wgUseDatabaseMessages'] = false;
1784  // Don't cache langconv tables
1785  $GLOBALS['wgLanguageConverterCacheType'] = CACHE_NONE;
1786  // Debug-friendly
1787  $GLOBALS['wgShowExceptionDetails'] = true;
1788  $GLOBALS['wgShowHostnames'] = true;
1789  // Don't break forms
1790  $GLOBALS['wgExternalLinkTarget'] = '_blank';
1791 
1792  // Allow multiple ob_flush() calls
1793  $GLOBALS['wgDisableOutputCompression'] = true;
1794 
1795  // Use a sensible cookie prefix (not my_wiki)
1796  $GLOBALS['wgCookiePrefix'] = 'mw_installer';
1797 
1798  // Some of the environment checks make shell requests, remove limits
1799  $GLOBALS['wgMaxShellMemory'] = 0;
1800 
1801  // Override the default CookieSessionProvider with a dummy
1802  // implementation that won't stomp on PHP's cookies.
1803  $GLOBALS['wgSessionProviders'] = [
1804  [
1805  'class' => InstallerSessionProvider::class,
1806  'args' => [ [
1807  'priority' => 1,
1808  ] ]
1809  ]
1810  ];
1811 
1812  // Don't try to use any object cache for SessionManager either.
1813  $GLOBALS['wgSessionCacheType'] = CACHE_NONE;
1814 
1815  // Set a dummy $wgServer to bypass the check in Setup.php, the
1816  // web installer will automatically detect it and not use this value.
1817  $GLOBALS['wgServer'] = 'https://🌻.invalid';
1818  }
1819 
1827  public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
1828  $this->extraInstallSteps[$findStep][] = $callback;
1829  }
1830 
1835  protected function disableTimeLimit() {
1836  Wikimedia\suppressWarnings();
1837  set_time_limit( 0 );
1838  Wikimedia\restoreWarnings();
1839  }
1840 }
static getDBInstallerClass( $type)
Get the DatabaseInstaller class name for this type.
Definition: Installer.php:564
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:142
envCheckServer()
Environment check to inform user which server we&#39;ve assumed.
Definition: Installer.php:958
static newFatal( $message,... $parameters)
Factory function for fatal errors.
Definition: StatusValue.php:69
array $internalDefaults
Variables that are stored alongside globals, and are used for any configuration of the installation p...
Definition: Installer.php:200
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
Definition: router.php:42
static array $mLangObjCache
Definition: Language.php:101
static factory( $url, array $options=null, $caller=__METHOD__)
Generate a new request object.
Title $parserTitle
Cached Title, used by parse().
Definition: Installer.php:93
array $dbInstallers
Cached DB installer instances, access using getDBInstaller().
Definition: Installer.php:79
restoreLinkPopups()
Definition: Installer.php:721
static newMainPage(MessageLocalizer $localizer=null)
Create a new Title for the Main Page.
Definition: Title.php:646
$IP
Definition: WebStart.php:41
Copyright (C) 2018 Kunal Mehta legoktm@member.fsf.org
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
Definition: Installer.php:1166
static getInstallerConfig(Config $baseConfig)
Constructs a Config object that contains configuration settings that should be overwritten for the in...
Definition: Installer.php:370
if(!isset( $args[0])) $lang
envCheckShellLocale()
Environment check for preferred locale in shell.
Definition: Installer.php:984
includeExtensions()
Installs the auto-detected extensions.
Definition: Installer.php:1484
envCheckGraphics()
Environment check for ImageMagick and GD.
Definition: Installer.php:910
Class for the core installer web interface.
$source
doEnvironmentPreps()
Definition: Installer.php:518
envCheckGit()
Search for git.
Definition: Installer.php:936
static getInstance( $id)
Get a cached instance of the specified type of cache object.
Definition: ObjectCache.php:78
array $settings
Definition: Installer.php:65
envCheckDiff3()
Search for GNU diff3.
Definition: Installer.php:887
ParserOptions $parserOptions
Cached ParserOptions, used by parse().
Definition: Installer.php:100
envCheckModSecurity()
Scare user to death if they have mod_security or mod_security2.
Definition: Installer.php:874
warning( $message,... $parameters)
Add a new warning.
An interwiki lookup that has no data, intended for use in the installer.
wfIsWindows()
Check if the operating system is Windows.
static canMakeRequests()
Simple function to test if we can make any sort of requests at all, using cURL or fopen() ...
$wgMemc
Definition: Setup.php:768
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:646
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
dirIsExecutable( $dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
Definition: Installer.php:1180
const CACHE_MEMCACHED
Definition: Defines.php:84
getConnection()
Connect to the database using the administrative user/password currently defined in the session...
static stripOuterParagraph( $html)
Strip outer.
Definition: Parser.php:6387
array $objectCaches
Known object cache types and the functions used to test for their existence.
Definition: Installer.php:252
envCheck64Bit()
Checks if we&#39;re running on 64 bit or not.
Definition: Installer.php:1103
showMessage( $msg,... $params)
UI interface for displaying a short message The parameters are like parameters to wfMessage()...
$wgExtensionDirectory
Filesystem extensions directory.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
envCheckSuhosinMaxValueLength()
Checks if suhosin.get.max_value_length is set, and if so generate a warning because it is incompatibl...
Definition: Installer.php:1085
$mediaWikiAnnounceLanguages
Supported language codes for Mailman.
Definition: Installer.php:331
$wgLang
Definition: Setup.php:858
static getMain()
Get the RequestContext object associated with the main request.
generateKeys()
Generate $wgSecretKey.
Definition: Installer.php:1639
Interface for configuration instances.
Definition: Config.php:28
static maybeGetWebserverPrimaryGroup()
On POSIX systems return the primary group of the webserver we&#39;re running under.
Definition: Installer.php:663
getExtensionInfo( $type, $parentRelPath, $name)
Definition: Installer.php:1332
setParserLanguage( $lang)
ParserOptions are constructed before we determined the language, so fix it.
Definition: Installer.php:1246
array $envPreps
A list of environment preparation methods called by doEnvironmentPreps().
Definition: Installer.php:151
array $envChecks
A list of environment check methods called by doEnvironmentChecks().
Definition: Installer.php:128
addInstallStep( $callback, $findStep='BEGINNING')
Add an installation step following the given step.
Definition: Installer.php:1827
static factory(array $deltas)
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
getDBInstaller( $type=false)
Get an instance of DatabaseInstaller for the specified DB type.
Definition: Installer.php:575
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
Definition: Installer.php:595
doGenerateKeys( $keys)
Generate a secret value for variables using a secure generator.
Definition: Installer.php:1654
int $minMemorySize
Minimum memory size in MB.
Definition: Installer.php:86
getInstallSteps(DatabaseInstaller $installer)
Get an array of install steps.
Definition: Installer.php:1548
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
Definition: Installer.php:635
array $compiledDBs
List of detected DBs, access using getCompiledDBs().
Definition: Installer.php:72
getParserOptions()
Definition: Installer.php:713
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format...
Definition: MWCryptRand.php:36
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:544
findExtensions( $directory='extensions')
Find extensions or skins in a subdirectory of $IP.
Definition: Installer.php:1269
disableTimeLimit()
Disable the time limit for execution.
Definition: Installer.php:1835
static apacheModulePresent( $moduleName)
Checks for presence of an Apache module.
Definition: Installer.php:1229
$GLOBALS['IP']
Content object for wiki text pages.
Provides a fallback sequence for Config objects.
Definition: MultiConfig.php:28
$wgHooks
Global list of hooks.
array array $rightsProfiles
User rights profiles.
Definition: Installer.php:263
createMainpage(DatabaseInstaller $installer)
Insert Main Page with default content.
Definition: Installer.php:1744
static findInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
disableLinkPopups()
Definition: Installer.php:717
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
Definition: Installer.php:693
envCheckCache()
Environment check for compiled object cache types.
Definition: Installer.php:855
envCheckUploadsDirectory()
Environment check for the permissions of the uploads directory.
Definition: Installer.php:1066
performInstallation( $startCB, $endCB)
Actually perform the installation.
Definition: Installer.php:1602
const MINIMUM_PCRE_VERSION
The oldest version of PCRE we can support.
Definition: Installer.php:60
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:560
envCheckDB()
Environment check for DB types.
Definition: Installer.php:761
showError( $msg,... $params)
Same as showMessage(), but for displaying errors.
$lines
Definition: router.php:61
getDocUrl( $page)
Overridden by WebInstaller to provide lastPage parameters.
Definition: Installer.php:1256
populateSiteStats(DatabaseInstaller $installer)
Install step which adds a row to the site_stats table with appropriate initial values.
Definition: Installer.php:734
Show an error when any operation involving passwords fails to run.
array $extraInstallSteps
Extra steps for installation, for things like DatabaseInstallers to modify.
Definition: Installer.php:245
getCompiledDBs()
Get a list of DBs supported by current PHP setup.
Definition: Installer.php:553
const EDIT_NEW
Definition: Defines.php:132
array array array $licenses
License types.
Definition: Installer.php:288
envGetDefaultServer()
Helper function to be called from envPrepServer()
envCheckPCRE()
Environment check for the PCRE module.
Definition: Installer.php:807
envCheckPath()
Environment check to inform user which paths we&#39;ve assumed.
Definition: Installer.php:971
const CACHE_ANYTHING
Definition: Defines.php:81
__construct()
Constructor, always call this from child classes.
Definition: Installer.php:408
$wgStyleDirectory
Filesystem stylesheets directory.
static array $dbTypes
Known database types.
Definition: Installer.php:111
if(!is_readable( $file)) $ext
Definition: router.php:48
Base class for DBMS-specific installation helper classes.
static overrideConfig()
Override the necessary bits of the config to run an installation.
Definition: Installer.php:1775
Base installer class.
Definition: Installer.php:52
$line
Definition: mcc.php:119
$wgObjectCaches
Advanced object cache configuration.
$content
Definition: router.php:78
static getDBTypes()
Get a list of known DB types.
Definition: Installer.php:476
$wgAutoloadClasses
Array mapping class names to filenames, for autoloading.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
Definition: Installer.php:530
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:536
findExtensionsByType( $type='extension', $directory='extensions')
Find extensions or skins, and return an array containing the value for &#39;Name&#39; for each found extensio...
Definition: Installer.php:1289
const CACHE_NONE
Definition: Defines.php:82
envCheckLibicu()
Check the libicu version.
Definition: Installer.php:1114
$wgExternalLinkTarget
Set a default target for external links, e.g.
envCheckMemory()
Environment check for available memory.
Definition: Installer.php:829
doEnvironmentChecks()
Do initial checks of the PHP environment.
Definition: Installer.php:493
createSysop()
Create the first user account, grant it sysop, bureaucrat and interface-admin rights.
Definition: Installer.php:1670
A Config instance which stores all settings as a member variable.
Definition: HashConfig.php:28
readExtension( $fullJsonFile, $extDeps=[], $skinDeps=[])
Definition: Installer.php:1385
envPrepServer()
Environment prep for the server hostname.
Definition: Installer.php:1150
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
array array array $mediaWikiAnnounceUrl
URL to mediawiki-announce subscription.
Definition: Installer.php:325
array $defaultVarNames
MediaWiki configuration globals that will eventually be passed through to LocalSettings.php.
Definition: Installer.php:163
const CACHE_DB
Definition: Defines.php:83
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
Definition: User.php:758
subscribeToMediaWikiAnnounce(Status $s)
Definition: Installer.php:1712
array array [] $installSteps
The actual list of installation steps.
Definition: Installer.php:238
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:317
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings, but will fall back to another if the default skin is missing and some other one is present instead.
Definition: Installer.php:1469