68 'https://lists.wikimedia.org/postorius/lists/mediawiki-announce.lists.wikimedia.org/';
141 'envCheckModSecurity',
147 'envCheckShellLocale',
148 'envCheckUploadsDirectory',
150 'envCheckSuhosinMaxValueLength',
183 'wgEmailAuthentication',
187 'wgImageMagickConvertCommand',
192 'wgDeletedDirectory',
196 'wgUseInstantCommons',
211 '_Environment' =>
false,
212 '_RaiseMemory' =>
false,
213 '_UpgradeDone' =>
false,
214 '_InstallDone' =>
false,
216 '_InstallPassword' =>
'',
217 '_SameAccount' =>
true,
218 '_CreateDBAccount' =>
false,
219 '_NamespaceType' =>
'site-name',
221 '_AdminPassword' =>
'',
222 '_AdminPasswordConfirm' =>
'',
224 '_Subscribe' =>
false,
225 '_SkipOptional' =>
'continue',
226 '_RightsProfile' =>
'wiki',
227 '_LicenseCode' =>
'none',
231 '_MemCachedServers' =>
'',
232 '_UpgradeKeySupplied' =>
false,
233 '_ExistingDBSettings' =>
false,
235 '_Logo' =>
'$wgResourceBasePath/resources/assets/wiki.png',
237 'wgAuthenticationTokenVersion' => 1,
261 'apcu' =>
'apcu_fetch',
262 'wincache' =>
'wincache_ucache_get'
273 '*' => [
'edit' => false ]
277 'createaccount' =>
false,
283 'createaccount' =>
false,
297 'url' =>
'https://creativecommons.org/licenses/by/4.0/',
298 'icon' =>
'$wgResourceBasePath/resources/assets/licenses/cc-by.png',
301 'url' =>
'https://creativecommons.org/licenses/by-sa/4.0/',
302 'icon' =>
'$wgResourceBasePath/resources/assets/licenses/cc-by-sa.png',
305 'url' =>
'https://creativecommons.org/licenses/by-nc-sa/4.0/',
306 'icon' =>
'$wgResourceBasePath/resources/assets/licenses/cc-by-nc-sa.png',
309 'url' =>
'https://creativecommons.org/publicdomain/zero/1.0/',
310 'icon' =>
'$wgResourceBasePath/resources/assets/licenses/cc-0.png',
313 'url' =>
'https://www.gnu.org/copyleft/fdl.html',
314 'icon' =>
'$wgResourceBasePath/resources/assets/licenses/gnu-fdl.png',
372 $emptyCache = [
'class' => EmptyBagOStuff::class ];
379 ] + $baseConfig->
get(
'ObjectCaches' );
384 $messageDirs = $baseConfig->
get(
'MessagesDirs' );
385 $messageDirs[
'MediawikiInstaller'] = __DIR__ .
'/i18n';
387 $configOverrides->set(
'MessagesDirs', $messageDirs );
389 $installerConfig =
new MultiConfig( [ $configOverrides, $baseConfig ] );
392 $configRegistry = $baseConfig->
get(
'ConfigRegistry' );
393 $configRegistry[
'main'] =
static function () use ( $installerConfig ) {
394 return $installerConfig;
397 $configOverrides->set(
'ConfigRegistry', $configRegistry );
399 return $installerConfig;
412 MediaWikiServices::disableStorageBackend();
416 foreach ( $this->defaultVarNames as $var ) {
417 $this->settings[$var] = $GLOBALS[$var];
422 $this->compiledDBs = [];
423 foreach ( self::getDBTypes() as
$type ) {
426 if ( !$installer->isCompiled() ) {
429 $this->compiledDBs[] =
$type;
432 $this->parserTitle = Title::newFromText(
'Installer' );
452 $serviceOverrides += [
454 'InterwikiLookup' =>
static function () {
460 return $services->get(
'_DefaultOptionsLookup' );
467 MediaWikiServices::resetGlobalInstance( $installerConfig );
469 $mwServices = MediaWikiServices::getInstance();
471 foreach ( $serviceOverrides as $name => $callback ) {
475 $mwServices->redefineService( $name, $callback );
480 $mwServices->getLocalisationCache()->disableBackend();
488 RequestContext::getMain()->setUser( $user );
494 RequestContext::getMain()->setLanguage(
$lang );
495 $wgLang = RequestContext::getMain()->getLanguage();
503 $this->
setParserLanguage( $mwServices->getLanguageFactory()->getLanguage(
'en' ) );
533 $this->
showMessage(
'config-env-php', PHP_VERSION );
537 $pcreVersion = explode(
' ', PCRE_VERSION, 2 )[0];
538 if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION,
'<' ) ) {
539 $this->
showError(
'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
542 foreach ( $this->envChecks as $check ) {
543 $status = $this->$check();
544 if ( $status ===
false ) {
550 $this->
setVar(
'_Environment', $good );
552 return $good ? Status::newGood() : Status::newFatal(
'config-env-bad' );
556 foreach ( $this->envPreps as $prep ) {
567 public function setVar( $name, $value ) {
568 $this->settings[$name] = $value;
581 public function getVar( $name, $default =
null ) {
582 return $this->settings[$name] ?? $default;
602 return ucfirst(
$type ) .
'Installer';
619 if ( !isset( $this->dbInstallers[
$type] ) ) {
621 $this->dbInstallers[
$type] =
new $class( $this );
624 return $this->dbInstallers[
$type];
648 Wikimedia\suppressWarnings();
649 $_lsExists = file_exists(
"$IP/LocalSettings.php" );
650 Wikimedia\restoreWarnings();
657 require
"$IP/includes/DefaultSettings.php";
658 require
"$IP/LocalSettings.php";
660 return get_defined_vars();
673 return str_repeat(
'*', strlen( $realPassword ) );
684 if ( !preg_match(
'/^\*+$/', $value ) ) {
685 $this->
setVar( $name, $value );
701 if ( !function_exists(
'posix_getegid' ) || !function_exists(
'posix_getpwuid' ) ) {
702 # I don't know this, this isn't UNIX.
706 # posix_getegid() *not* getmygid() because we want the group of the webserver,
707 # not whoever owns the current script.
708 $gid = posix_getegid();
709 return posix_getpwuid( $gid )[
'name'] ??
null;
728 public function parse( $text, $lineStart =
false ) {
729 $parser = MediaWikiServices::getInstance()->getParser();
732 $out = $parser->parse( $text, $this->parserTitle, $this->parserOptions, $lineStart );
733 $html = $out->getText( [
734 'enableSectionEditLinks' =>
false,
738 }
catch (
Wikimedia\Services\ServiceDisabledException $e ) {
739 $html =
'<!--DB access attempted during parse--> ' . htmlspecialchars( $text );
753 $this->parserOptions->setExternalLinkTarget(
false );
771 if ( !$status->isOK() ) {
775 $status->value->insert(
779 'ss_total_edits' => 0,
780 'ss_good_articles' => 0,
781 'ss_total_pages' => 0,
783 'ss_active_users' => 0,
790 return Status::newGood();
800 $dbType = $this->
getVar(
'wgDBtype' );
805 foreach ( self::getDBTypes() as $name ) {
806 $allNames[] =
wfMessage(
"config-type-$name" )->text();
811 $databases = array_flip( $databases );
813 foreach ( array_keys( $databases ) as $db ) {
815 $status = $installer->checkPrerequisites();
816 if ( !$status->isGood() ) {
817 if ( !$this instanceof
WebInstaller && $db === $dbType ) {
824 unset( $databases[$db] );
827 $databases = array_flip( $databases );
829 $this->
showError(
'config-no-db', $wgLang->commaList( $allNames ), count( $allNames ) );
844 Wikimedia\suppressWarnings();
845 $regexd = preg_replace(
'/[\x{0430}-\x{04FF}]/iu',
'',
'-АБВГД-' );
850 $regexprop = preg_replace(
'/\p{Zs}/u',
'',
"-\u{3000}-" );
851 Wikimedia\restoreWarnings();
852 if ( $regexd !=
'--' || $regexprop !=
'--' ) {
853 $this->
showError(
'config-pcre-no-utf8' );
861 if ( preg_match(
'/^b.*c$/',
'bąc' ) === 0 ) {
862 $this->
showError(
'config-pcre-invalid-newline' );
875 $limit = ini_get(
'memory_limit' );
877 if ( !$limit || $limit == -1 ) {
883 if ( $n < $this->minMemorySize * 1024 * 1024 ) {
884 $newLimit =
"{$this->minMemorySize}M";
886 if ( ini_set(
"memory_limit", $newLimit ) ===
false ) {
889 $this->
showMessage(
'config-memory-raised', $limit, $newLimit );
890 $this->
setVar(
'_RaiseMemory',
true );
902 foreach ( $this->objectCaches as $name => $function ) {
903 if ( function_exists( $function ) ) {
904 $caches[$name] =
true;
912 $this->
setVar(
'_Caches', $caches );
920 if ( self::apacheModulePresent(
'mod_security' )
921 || self::apacheModulePresent(
'mod_security2' ) ) {
933 $names = [
"gdiff3",
"diff3" ];
935 $names[] =
'diff3.exe';
937 $versionInfo = [
'--version',
'GNU diffutils' ];
939 $diff3 = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
942 $this->
setVar(
'wgDiff3', $diff3 );
944 $this->
setVar(
'wgDiff3',
false );
956 $names =
wfIsWindows() ?
'convert.exe' :
'convert';
957 $versionInfo = [
'-version',
'ImageMagick' ];
958 $convert = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
960 $this->
setVar(
'wgImageMagickConvertCommand',
'' );
962 $this->
setVar(
'wgImageMagickConvertCommand', $convert );
963 $this->
showMessage(
'config-imagemagick', $convert );
964 } elseif ( function_exists(
'imagejpeg' ) ) {
981 $versionInfo = [
'--version',
'git version' ];
983 $git = ExecutableFinder::findInDefaultPaths( $names, $versionInfo );
986 $this->
setVar(
'wgGitBin', $git );
989 $this->
setVar(
'wgGitBin',
false );
1003 if ( $server !==
null ) {
1004 $this->
showMessage(
'config-using-server', $server );
1017 $this->
getVar(
'wgServer' ),
1018 $this->
getVar(
'wgScriptPath' )
1028 $os = php_uname(
's' );
1029 $supported = [
'Linux',
'SunOS',
'HP-UX',
'Darwin' ]; # Tested these
1031 if ( !in_array( $os, $supported ) ) {
1035 if ( Shell::isDisabled() ) {
1039 # Get a list of available locales.
1040 $result = Shell::command(
'/usr/bin/locale',
'-a' )->execute();
1042 if ( $result->getExitCode() != 0 ) {
1046 $lines = $result->getStdout();
1048 $candidatesByLocale = [];
1049 $candidatesByLang = [];
1051 if (
$line ===
'' ) {
1055 if ( !preg_match(
'/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i',
$line, $m ) ) {
1059 list( ,
$lang, , , ) = $m;
1061 $candidatesByLocale[$m[0]] = $m;
1062 $candidatesByLang[
$lang][] = $m;
1065 # Try the current value of LANG.
1066 if ( isset( $candidatesByLocale[getenv(
'LANG' )] ) ) {
1067 $this->
setVar(
'wgShellLocale', getenv(
'LANG' ) );
1072 # Try the most common ones.
1073 $commonLocales = [
'C.UTF-8',
'en_US.UTF-8',
'en_US.utf8',
'de_DE.UTF-8',
'de_DE.utf8' ];
1074 foreach ( $commonLocales as $commonLocale ) {
1075 if ( isset( $candidatesByLocale[$commonLocale] ) ) {
1076 $this->
setVar(
'wgShellLocale', $commonLocale );
1082 # Is there an available locale in the Wiki's language?
1083 $wikiLang = $this->
getVar(
'wgLanguageCode' );
1085 if ( isset( $candidatesByLang[$wikiLang] ) ) {
1086 $m = reset( $candidatesByLang[$wikiLang] );
1087 $this->
setVar(
'wgShellLocale', $m[0] );
1092 # Are there any at all?
1093 if ( count( $candidatesByLocale ) ) {
1094 $m = reset( $candidatesByLocale );
1095 $this->
setVar(
'wgShellLocale', $m[0] );
1111 $dir =
$IP .
'/images/';
1112 $url = $this->
getVar(
'wgServer' ) . $this->
getVar(
'wgScriptPath' ) .
'/images/';
1116 $this->
showMessage(
'config-uploads-not-safe', $dir );
1128 $currentValue = ini_get(
'suhosin.get.max_value_length' );
1129 $minRequired = 2000;
1130 $recommended = 5000;
1131 if ( $currentValue > 0 && $currentValue < $minRequired ) {
1132 $this->
showError(
'config-suhosin-max-value-length', $currentValue, $minRequired, $recommended );
1146 if ( PHP_INT_SIZE == 4 ) {
1164 $not_normal_c =
"\u{FA6C}";
1165 $normal_c =
"\u{242EE}";
1167 $intl = normalizer_normalize( $not_normal_c, Normalizer::FORM_C );
1169 $this->
showMessage(
'config-unicode-using-intl' );
1170 if ( $intl !== $normal_c ) {
1171 $this->
showMessage(
'config-unicode-update-warning' );
1180 if ( $server !==
null ) {
1181 $this->
setVar(
'wgServer', $server );
1196 $IP = dirname( dirname( __DIR__ ) );
1197 $this->
setVar(
'IP', $IP );
1211 "<?php echo 'exec';",
1212 "#!/var/env php\n<?php echo 'exec';",
1219 $httpRequestFactory = MediaWikiServices::getInstance()->getHttpRequestFactory();
1221 Wikimedia\suppressWarnings();
1223 foreach ( $scriptTypes as
$ext => $contents ) {
1224 foreach ( $contents as
$source ) {
1232 $text = $httpRequestFactory->get(
1237 }
catch ( Exception $e ) {
1242 unlink( $dir .
$file );
1244 if ( $text ==
'exec' ) {
1245 Wikimedia\restoreWarnings();
1252 Wikimedia\restoreWarnings();
1264 if ( function_exists(
'apache_get_modules' ) && in_array( $moduleName, apache_get_modules() ) ) {
1269 phpinfo( INFO_MODULES );
1270 $info = ob_get_clean();
1272 return strpos( $info, $moduleName ) !==
false;
1281 $this->parserOptions->setTargetLanguage(
$lang );
1282 $this->parserOptions->setUserLang(
$lang );
1291 return "{$_SERVER['PHP_SELF']}?page=" . urlencode( $page );
1304 switch ( $directory ) {
1310 throw new InvalidArgumentException(
"Invalid extension type" );
1324 if ( $this->
getVar(
'IP' ) ===
null ) {
1325 return Status::newGood( [] );
1328 $extDir = $this->
getVar(
'IP' ) .
'/' . $directory;
1329 if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
1330 return Status::newGood( [] );
1334 $dh = opendir( $extDir );
1337 while ( (
$file = readdir( $dh ) ) !==
false ) {
1339 if ( !is_dir(
"$extDir/$file" ) ||
$file[0] ===
'.' ) {
1343 if ( $extStatus->isOK() ) {
1344 $exts[
$file] = $extStatus->value;
1345 } elseif ( $extStatus->hasMessage(
'config-extension-not-found' ) ) {
1347 $status->warning(
'config-extension-not-found',
$file );
1349 $status->merge( $extStatus );
1353 uksort( $exts,
'strnatcasecmp' );
1355 $status->value = $exts;
1368 if ( $this->
getVar(
'IP' ) ===
null ) {
1369 throw new Exception(
'Cannot find extensions since the IP variable is not yet set' );
1371 if (
$type !==
'extension' &&
$type !==
'skin' ) {
1372 throw new InvalidArgumentException(
"Invalid extension type" );
1374 $absDir = $this->
getVar(
'IP' ) .
"/$parentRelPath/$name";
1375 $relDir =
"../$parentRelPath/$name";
1376 if ( !is_dir( $absDir ) ) {
1377 return Status::newFatal(
'config-extension-not-found', $name );
1379 $jsonFile =
$type .
'.json';
1380 $fullJsonFile =
"$absDir/$jsonFile";
1381 $isJson = file_exists( $fullJsonFile );
1385 $fullPhpFile =
"$absDir/$name.php";
1386 $isPhp = file_exists( $fullPhpFile );
1388 if ( !$isJson && !$isPhp ) {
1389 return Status::newFatal(
'config-extension-not-found', $name );
1394 if ( is_dir(
"$absDir/screenshots" ) ) {
1395 $paths = glob(
"$absDir/screenshots/*.png" );
1396 foreach ( $paths as
$path ) {
1397 $info[
'screenshots'][] = str_replace( $absDir, $relDir,
$path );
1403 if ( !$jsonStatus->isOK() ) {
1406 $info += $jsonStatus->value;
1410 return Status::newGood( $info );
1421 private function readExtension( $fullJsonFile, $extDeps = [], $skinDeps = [] ) {
1426 $extDir = $this->
getVar(
'IP' ) .
'/extensions';
1427 foreach ( $extDeps as $dep ) {
1428 $fname =
"$extDir/$dep/extension.json";
1429 if ( !file_exists( $fname ) ) {
1430 return Status::newFatal(
'config-extension-not-found', $dep );
1436 $skinDir = $this->
getVar(
'IP' ) .
'/skins';
1437 foreach ( $skinDeps as $dep ) {
1438 $fname =
"$skinDir/$dep/skin.json";
1439 if ( !file_exists( $fname ) ) {
1440 return Status::newFatal(
'config-extension-not-found', $dep );
1447 $info = $registry->readFromQueue( $load );
1449 if ( $e->incompatibleCore || $e->incompatibleSkins
1450 || $e->incompatibleExtensions
1454 return Status::newFatal(
'config-extension-dependency',
1455 basename( dirname( $fullJsonFile ) ), $e->getMessage() );
1456 } elseif ( $e->missingExtensions || $e->missingSkins ) {
1461 array_merge( $extDeps, $e->missingExtensions ),
1462 array_merge( $skinDeps, $e->missingSkins )
1464 if ( !$status->isOK() && !$status->hasMessage(
'config-extension-dependency' ) ) {
1465 $status = Status::newFatal(
'config-extension-dependency',
1466 basename( dirname( $fullJsonFile ) ), $status->getMessage() );
1471 return Status::newFatal(
'config-extension-dependency',
1472 basename( dirname( $fullJsonFile ) ), $e->getMessage() );
1479 foreach ( $info[
'credits'] as $name => $credit ) {
1485 $type = basename( $credit[
'path'] ) ===
'skin.json' ?
'skins' :
'extensions';
1486 $ret[
'requires'][
$type][] = $credit[
'name'];
1488 $credits = array_values( $info[
'credits'] )[0];
1489 if ( isset( $credits[
'url'] ) ) {
1490 $ret[
'url'] = $credits[
'url'];
1492 $ret[
'type'] = $credits[
'type'];
1494 return Status::newGood( $ret );
1506 $defaultSkin = $GLOBALS[
'wgDefaultSkin'];
1507 if ( !$skinNames || in_array( $defaultSkin, $skinNames ) ) {
1508 return $defaultSkin;
1510 return $skinNames[0];
1522 define(
'MW_EXTENSIONS_LOADED',
true );
1526 if ( isset( $data[
'globals'][
'wgHooks'][
'LoadExtensionSchemaUpdates'] ) ) {
1527 $legacySchemaHooks = array_merge( $legacySchemaHooks,
1528 $data[
'globals'][
'wgHooks'][
'LoadExtensionSchemaUpdates'] );
1530 $extDeprecatedHooks = $data[
'attributes'][
'DeprecatedHooks'] ?? [];
1534 [
'LoadExtensionSchemaUpdates' => $legacySchemaHooks ],
1535 $data[
'attributes'][
'Hooks'] ?? [],
1538 MediaWikiServices::getInstance()->getObjectFactory()
1541 return Status::newGood();
1552 $exts = $this->
getVar(
'_Extensions' );
1553 $installPath = $this->
getVar(
'IP' );
1555 foreach ( $exts as $e ) {
1556 if ( file_exists(
"$installPath/extensions/$e/$e.php" ) ) {
1557 $files[] =
"$installPath/extensions/$e/$e.php";
1588 require
"$IP/includes/DefaultSettings.php";
1592 foreach ( $files as
$file ) {
1598 $hooksWeWant =
$wgHooks[
'LoadExtensionSchemaUpdates'] ?? [];
1603 return [
'LoadExtensionSchemaUpdates' => $hooksWeWant ];
1613 $exts = $this->
getVar(
'_Extensions' );
1614 $installPath = $this->
getVar(
'IP' );
1616 foreach ( $exts as $e ) {
1617 if ( file_exists(
"$installPath/extensions/$e/extension.json" ) ) {
1618 $queue[
"$installPath/extensions/$e/extension.json"] = 1;
1623 $data = $registry->readFromQueue(
$queue );
1637 if ( !$this->autoExtensionHookContainer ) {
1638 throw new \Exception( __METHOD__ .
1639 ': includeExtensions() has not been called' );
1658 $coreInstallSteps = [
1659 [
'name' =>
'database',
'callback' => [ $installer,
'setupDatabase' ] ],
1660 [
'name' =>
'tables',
'callback' => [ $installer,
'createTables' ] ],
1661 [
'name' =>
'tables-manual',
'callback' => [ $installer,
'createManualTables' ] ],
1662 [
'name' =>
'interwiki',
'callback' => [ $installer,
'populateInterwikiTable' ] ],
1663 [
'name' =>
'stats',
'callback' => [ $this,
'populateSiteStats' ] ],
1664 [
'name' =>
'keys',
'callback' => [ $this,
'generateKeys' ] ],
1665 [
'name' =>
'updates',
'callback' => [ $installer,
'insertUpdateKeys' ] ],
1666 [
'name' =>
'restore-services',
'callback' => [ $this,
'restoreServices' ] ],
1667 [
'name' =>
'sysop',
'callback' => [ $this,
'createSysop' ] ],
1668 [
'name' =>
'mainpage',
'callback' => [ $this,
'createMainpage' ] ],
1673 foreach ( $coreInstallSteps as $step ) {
1674 $this->installSteps[] = $step;
1675 if ( isset( $this->extraInstallSteps[$step[
'name']] ) ) {
1676 $this->installSteps = array_merge(
1677 $this->installSteps,
1678 $this->extraInstallSteps[$step[
'name']]
1684 if ( isset( $this->extraInstallSteps[
'BEGINNING'] ) ) {
1685 $this->installSteps = array_merge(
1686 $this->extraInstallSteps[
'BEGINNING'],
1692 if ( count( $this->
getVar(
'_Extensions' ) ) ) {
1693 array_unshift( $this->installSteps,
1694 [
'name' =>
'extensions',
'callback' => [ $this,
'includeExtensions' ] ]
1696 $this->installSteps[] = [
1697 'name' =>
'extension-tables',
1698 'callback' => [ $installer,
'createExtensionTables' ]
1714 $installResults = [];
1716 $installer->preInstall();
1718 foreach ( $steps as $stepObj ) {
1719 $name = $stepObj[
'name'];
1720 call_user_func_array( $startCB, [ $name ] );
1723 $status = call_user_func( $stepObj[
'callback'], $installer );
1726 call_user_func( $endCB, $name, $status );
1727 $installResults[$name] = $status;
1731 if ( !$status->isOK() ) {
1735 if ( $status->isOK() ) {
1737 'config-install-db-success'
1739 $this->
setVar(
'_InstallDone',
true );
1742 return $installResults;
1751 $keys = [
'wgSecretKey' => 64 ];
1752 if ( strval( $this->
getVar(
'wgUpgradeKey' ) ) ===
'' ) {
1753 $keys[
'wgUpgradeKey'] = 16;
1766 return $services->get(
'UserOptionsManager' );
1769 return Status::newGood();
1779 foreach (
$keys as $name => $length ) {
1780 $secretKey = MWCryptRand::generateHex( $length );
1781 $this->
setVar( $name, $secretKey );
1783 return Status::newGood();
1792 $name = $this->
getVar(
'_AdminName' );
1797 return Status::newFatal(
'config-admin-error-user', $name );
1800 if ( $user->idForName() == 0 ) {
1801 $user->addToDatabase();
1803 $password = $this->
getVar(
'_AdminPassword' );
1804 $status = $user->changeAuthenticationData( [
1805 'username' => $user->getName(),
1806 'password' => $password,
1807 'retype' => $password,
1809 if ( !$status->isGood() ) {
1810 return Status::newFatal(
'config-admin-error-password',
1811 $name, $status->getWikiText(
null,
null, $this->getVar(
'_UserLang' ) ) );
1814 $userGroupManager = MediaWikiServices::getInstance()->getUserGroupManager();
1815 $userGroupManager->addUserToGroup( $user,
'sysop' );
1816 $userGroupManager->addUserToGroup( $user,
'bureaucrat' );
1817 $userGroupManager->addUserToGroup( $user,
'interface-admin' );
1818 if ( $this->
getVar(
'_AdminEmail' ) ) {
1819 $user->setEmail( $this->
getVar(
'_AdminEmail' ) );
1821 $user->saveSettings();
1824 $ssUpdate = SiteStatsUpdate::factory( [
'users' => 1 ] );
1825 $ssUpdate->doUpdate();
1828 if ( $this->
getVar(
'_Subscribe' ) && $this->
getVar(
'_AdminEmail' ) ) {
1831 return Status::newGood();
1838 $status = Status::newGood();
1839 $http = MediaWikiServices::getInstance()->getHttpRequestFactory();
1840 if ( !$http->canMakeRequests() ) {
1841 $status->warning(
'config-install-subscribe-fail',
1842 wfMessage(
'config-install-subscribe-notpossible' ) );
1847 $params = [
'email' => $this->
getVar(
'_AdminEmail' ) ];
1848 $req = $http->create( self::MEDIAWIKI_ANNOUNCE_URL .
'anonymous_subscribe',
1849 [
'method' =>
'POST',
'postData' => $params ], __METHOD__ );
1852 $token = str_repeat(
'a', 64 );
1853 $req->setHeader(
'Referer', self::MEDIAWIKI_ANNOUNCE_URL );
1854 $req->setHeader(
'Cookie',
"csrftoken=$token" );
1855 $req->setHeader(
'X-CSRFToken', $token );
1858 $reqStatus = $req->execute();
1859 if ( !$reqStatus->isOK() ) {
1860 $status->warning(
'config-install-subscribe-fail',
1861 Status::wrap( $reqStatus )->getMessage() );
1870 $checkReq = $http->create( self::MEDIAWIKI_ANNOUNCE_URL, [], __METHOD__ );
1871 $checkReq->setCookieJar( $req->getCookieJar() );
1872 if ( !$checkReq->execute()->isOK() ) {
1873 $status->warning(
'config-install-subscribe-possiblefail' );
1876 $html = $checkReq->getContent();
1877 if ( strpos( $html,
'Please check your inbox for further instructions' ) !==
false ) {
1879 } elseif ( strpos( $html,
'Member already subscribed' ) !==
false ) {
1880 $status->warning(
'config-install-subscribe-alreadysubscribed' );
1881 } elseif ( strpos( $html,
'Subscription request already pending' ) !==
false ) {
1882 $status->warning(
'config-install-subscribe-alreadypending' );
1884 $status->warning(
'config-install-subscribe-possiblefail' );
1896 $status = Status::newGood();
1897 $title = Title::newMainPage();
1898 if (
$title->exists() ) {
1899 $status->warning(
'config-install-mainpage-exists' );
1903 $page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle(
$title );
1905 wfMessage(
'mainpagetext' )->inContentLanguage()->text() .
"\n\n" .
1906 wfMessage(
'mainpagedocfooter' )->inContentLanguage()->text()
1909 $status = $page->doUserEditContent(
1915 }
catch ( Exception $e ) {
1917 $status->fatal(
'config-install-mainpage-failed', $e->getMessage() );
1929 if ( !defined(
'MW_NO_SESSION_HANDLER' ) ) {
1930 define(
'MW_NO_SESSION_HANDLER', 1 );
1934 $GLOBALS[
'wgUseDatabaseMessages'] =
false;
1936 $GLOBALS[
'wgLanguageConverterCacheType'] =
CACHE_NONE;
1938 $GLOBALS[
'wgResourceLoaderUseObjectCacheForDeps'] =
true;
1940 $GLOBALS[
'wgShowExceptionDetails'] =
true;
1941 $GLOBALS[
'wgShowHostnames'] =
true;
1943 $GLOBALS[
'wgExternalLinkTarget'] =
'_blank';
1946 $GLOBALS[
'wgDisableOutputCompression'] =
true;
1949 $GLOBALS[
'wgCookiePrefix'] =
'mw_installer';
1952 $GLOBALS[
'wgMaxShellMemory'] = 0;
1956 $GLOBALS[
'wgSessionProviders'] = [
1958 'class' => InstallerSessionProvider::class,
1973 $GLOBALS[
'wgServer'] =
'https://🌻.invalid';
1984 $this->extraInstallSteps[$findStep][] = $callback;
1992 Wikimedia\suppressWarnings();
1993 set_time_limit( 0 );
1994 Wikimedia\restoreWarnings();
$wgObjectCaches
Advanced object cache configuration.
$wgStyleDirectory
Filesystem stylesheets directory.
$wgAutoloadClasses
Array mapping class names to filenames, for autoloading.
$wgHooks
Global list of hooks.
$wgExtensionDirectory
Filesystem extensions directory.
$wgExternalLinkTarget
Set a default target for external links, e.g.
wfShorthandToInteger(?string $string='', int $default=-1)
Converts shorthand byte notation to integer form.
wfIsWindows()
Check if the operating system is Windows.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Base class for DBMS-specific installation helper classes.
getConnection()
Connect to the database using the administrative user/password currently defined in the session.
Copyright (C) 2018 Kunal Mehta legoktm@debian.org
The Registry loads JSON files, and uses a Processor to extract information from them.
Accesses configuration settings from $GLOBALS.
A Config instance which stores all settings as a member variable.
envPrepServer()
Environment prep for the server hostname.
parse( $text, $lineStart=false)
Convert wikitext $text to HTML.
array $compiledDBs
List of detected DBs, access using getCompiledDBs().
getExtensionInfo( $type, $parentRelPath, $name)
Title $parserTitle
Cached Title, used by parse().
includeExtensions()
Installs the auto-detected extensions.
createMainpage(DatabaseInstaller $installer)
Insert Main Page with default content.
const MINIMUM_PCRE_VERSION
The oldest version of PCRE we can support.
getDefaultSkin(array $skinNames)
Returns a default value to be used for $wgDefaultSkin: normally the one set in DefaultSettings,...
envCheckLibicu()
Check the libicu version.
getDBInstaller( $type=false)
Get an instance of DatabaseInstaller for the specified DB type.
envCheckDB()
Environment check for DB types.
envCheckSuhosinMaxValueLength()
Checks if suhosin.get.max_value_length is set, and if so generate a warning because it is incompatibl...
setVar( $name, $value)
Set a MW configuration variable, or internal installer configuration variable.
array $internalDefaults
Variables that are stored alongside globals, and are used for any configuration of the installation p...
envCheckModSecurity()
Scare user to death if they have mod_security or mod_security2.
getFakePassword( $realPassword)
Get a fake password for sending back to the user in HTML.
envCheckServer()
Environment check to inform user which server we've assumed.
disableTimeLimit()
Disable the time limit for execution.
static apacheModulePresent( $moduleName)
Checks for presence of an Apache module.
array $rightsProfiles
User rights profiles.
addInstallStep( $callback, $findStep='BEGINNING')
Add an installation step following the given step.
getCompiledDBs()
Get a list of DBs supported by current PHP setup.
ParserOptions $parserOptions
Cached ParserOptions, used by parse().
dirIsExecutable( $dir, $url)
Checks if scripts located in the given directory can be executed via the given URL.
envCheckGit()
Search for git.
getDocUrl( $page)
Overridden by WebInstaller to provide lastPage parameters.
array[] $installSteps
The actual list of installation steps.
array $defaultVarNames
MediaWiki configuration globals that will eventually be passed through to LocalSettings....
const MEDIAWIKI_ANNOUNCE_URL
URL to mediawiki-announce list summary page.
resetMediaWikiServices(Config $installerConfig=null, $serviceOverrides=[])
Reset the global service container and associated global state to accommodate different stages of the...
static getExistingLocalSettings()
Determine if LocalSettings.php exists.
static getInstallerConfig(Config $baseConfig)
Constructs a Config object that contains configuration settings that should be overwritten for the in...
restoreServices()
Restore services that have been redefined in the early stage of installation.
includeExtensionFiles( $files)
Include the specified extension PHP files.
getAutoExtensionData()
Auto-detect extensions with an extension.json file.
envCheckMemory()
Environment check for available memory.
array $objectCaches
Known object cache types and the functions used to test for their existence.
array $licenses
License types.
static maybeGetWebserverPrimaryGroup()
On POSIX systems return the primary group of the webserver we're running under.
doEnvironmentChecks()
Do initial checks of the PHP environment.
performInstallation( $startCB, $endCB)
Actually perform the installation.
getAutoExtensionLegacyHooks()
Auto-detect extensions with an old style .php registration file, load the extensions,...
envCheck64Bit()
Checks if we're running on 64 bit or not.
generateKeys()
Generate $wgSecretKey.
populateSiteStats(DatabaseInstaller $installer)
Install step which adds a row to the site_stats table with appropriate initial values.
envCheckCache()
Environment check for compiled object cache types.
__construct()
Constructor, always call this from child classes.
int $minMemorySize
Minimum memory size in MiB.
findExtensionsByType( $type='extension', $directory='extensions')
Find extensions or skins, and return an array containing the value for 'Name' for each found extensio...
doGenerateKeys( $keys)
Generate a secret value for variables using a secure generator.
showStatusMessage(Status $status)
Show a message to the installing user by using a Status object.
readExtension( $fullJsonFile, $extDeps=[], $skinDeps=[])
envCheckPath()
Environment check to inform user which paths we've assumed.
array $envPreps
A list of environment preparation methods called by doEnvironmentPreps().
setPassword( $name, $value)
Set a variable which stores a password, except if the new value is a fake password in which case leav...
envPrepPath()
Environment prep for setting $IP and $wgScriptPath.
static getDBTypes()
Get a list of known DB types.
createSysop()
Create the first user account, grant it sysop, bureaucrat and interface-admin rights.
envCheckPCRE()
Environment check for the PCRE module.
getVar( $name, $default=null)
Get an MW configuration variable, or internal installer configuration variable.
static getDBInstallerClass( $type)
Get the DatabaseInstaller class name for this type.
static overrideConfig()
Override the necessary bits of the config to run an installation.
array $extraInstallSteps
Extra steps for installation, for things like DatabaseInstallers to modify.
HookContainer null $autoExtensionHookContainer
static array $dbTypes
Known database types.
getAutoExtensionHookContainer()
Get the hook container previously populated by includeExtensions().
envCheckDiff3()
Search for GNU diff3.
subscribeToMediaWikiAnnounce()
envCheckShellLocale()
Environment check for preferred locale in shell.
envGetDefaultServer()
Helper function to be called from envPrepServer()
getInstallSteps(DatabaseInstaller $installer)
Get an array of install steps.
array $dbInstallers
Cached DB installer instances, access using getDBInstaller().
array $envChecks
A list of environment check methods called by doEnvironmentChecks().
envCheckGraphics()
Environment check for ImageMagick and GD.
showMessage( $msg,... $params)
UI interface for displaying a short message The parameters are like parameters to wfMessage().
showError( $msg,... $params)
Same as showMessage(), but for displaying errors.
envCheckUploadsDirectory()
Environment check for the permissions of the uploads directory.
setParserLanguage( $lang)
ParserOptions are constructed before we determined the language, so fix it.
findExtensions( $directory='extensions')
Find extensions or skins in a subdirectory of $IP.
Provides a fallback sequence for Config objects.
Set options of the Parser.
static stripOuterParagraph( $html)
Strip outer.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
static setUser( $user)
Reset the stub global user to a different "real" user object, while ensuring that any method calls on...
Represents a title within MediaWiki.
static newFromName( $name, $validate='valid')
static newFromId( $id)
Static factory method for creation from a given user ID.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
Class for the core installer web interface.
Content object for wiki text pages.
Interface for configuration instances.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!is_readable( $file)) $ext
if(!isset( $args[0])) $lang
if(!file_exists( $CREDITS)) $lines