X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSetup.php;h=39f0c8116f6d5accc21ba434a1a0996144a9f71b;hb=93d9da40d3153ee8f63ffbd7bc72f08d62e11efd;hp=45a2456c97d44d7944823b26abe5c5b4236518cd;hpb=e55888be363ad07d5817bd383b8078064ef0d36f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Setup.php b/includes/Setup.php index 45a2456c97..39f0c8116f 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -52,6 +52,17 @@ if ( ini_get( 'mbstring.func_overload' ) ) { die( 'MediaWiki does not support installations where mbstring.func_overload is non-zero.' ); } +// Define MW_ENTRY_POINT if it's not already, so that config code can check the +// value without using defined() +if ( !defined( 'MW_ENTRY_POINT' ) ) { + /** + * The entry point, which may be either the script filename without the + * file extension, or "cli" for maintenance scripts, or "unknown" for any + * entry point that does not set the constant. + */ + define( 'MW_ENTRY_POINT', 'unknown' ); +} + // Start the autoloader, so that extensions can derive classes from core files require_once "$IP/includes/AutoLoader.php"; @@ -96,7 +107,7 @@ if ( !interface_exists( 'Psr\Log\LoggerInterface' ) ) { // Install a header callback MediaWiki\HeaderCallback::register(); -// Set the encoding used by reading HTTP input, writing HTTP output. +// Set the encoding used by PHP for reading HTTP input, and writing output. // This is also the default for mbstring functions. mb_internal_encoding( 'UTF-8' ); @@ -128,9 +139,6 @@ if ( defined( 'MW_SETUP_CALLBACK' ) ) { * Main setup */ -$fname = 'Setup.php'; -$ps_setup = Profiler::instance()->scopedProfileIn( $fname ); - // Load queued extensions ExtensionRegistry::getInstance()->loadFromQueue(); // Don't let any other extensions load @@ -141,8 +149,6 @@ putenv( "LC_ALL=$wgShellLocale" ); setlocale( LC_ALL, $wgShellLocale ); // Set various default paths sensibly... -$ps_default = Profiler::instance()->scopedProfileIn( $fname . '-defaults' ); - if ( $wgScript === false ) { $wgScript = "$wgScriptPath/index.php"; } @@ -161,12 +167,6 @@ if ( $wgArticlePath === false ) { } } -if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) { - // 'view' is assumed the default action path everywhere in the code - // but is rarely filled in $wgActionPaths - $wgActionPaths['view'] = $wgArticlePath; -} - if ( $wgResourceBasePath === null ) { $wgResourceBasePath = $wgScriptPath; } @@ -368,19 +368,6 @@ foreach ( $wgForeignFileRepos as &$repo ) { unset( $repo ); // no global pollution; destroy reference $rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 ); -if ( $wgRCFilterByAge ) { - // Trim down $wgRCLinkDays so that it only lists links which are valid - // as determined by $wgRCMaxAge. - // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link. - sort( $wgRCLinkDays ); - - foreach ( $wgRCLinkDays as $i => $days ) { - if ( $days >= $rcMaxAgeDays ) { - array_splice( $wgRCLinkDays, $i + 1 ); - break; - } - } -} // Ensure that default user options are not invalid, since that breaks Special:Preferences $wgDefaultUserOptions['rcdays'] = min( $wgDefaultUserOptions['rcdays'], @@ -393,6 +380,8 @@ $wgDefaultUserOptions['watchlistdays'] = min( unset( $rcMaxAgeDays ); if ( $wgSkipSkin ) { + // Hard deprecated in 1.34. + wfDeprecated( '$wgSkipSkin – use $wgSkipSkins instead', '1.23' ); $wgSkipSkins[] = $wgSkipSkin; } @@ -400,6 +389,9 @@ $wgSkipSkins[] = 'fallback'; $wgSkipSkins[] = 'apioutput'; if ( $wgLocalInterwiki ) { + // Hard deprecated in 1.34. + wfDeprecated( '$wgLocalInterwiki – use $wgLocalInterwikis instead', '1.23' ); + // @phan-suppress-next-line PhanUndeclaredVariableDim array_unshift( $wgLocalInterwikis, $wgLocalInterwiki ); } @@ -452,17 +444,6 @@ if ( $wgMetaNamespace === false ) { $wgMetaNamespace = str_replace( ' ', '_', $wgSitename ); } -// Default value is 2000 or the suhosin limit if it is between 1 and 2000 -if ( $wgResourceLoaderMaxQueryLength === false ) { - $suhosinMaxValueLength = (int)ini_get( 'suhosin.get.max_value_length' ); - if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) { - $wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength; - } else { - $wgResourceLoaderMaxQueryLength = 2000; - } - unset( $suhosinMaxValueLength ); -} - // Ensure the minimum chunk size is less than PHP upload limits or the maximum // upload size. $wgMinUploadChunkSize = min( @@ -479,25 +460,7 @@ $wgMinUploadChunkSize = min( * Definitions of the NS_ constants are in Defines.php * @private */ -$wgCanonicalNamespaceNames = [ - NS_MEDIA => 'Media', - NS_SPECIAL => 'Special', - NS_TALK => 'Talk', - NS_USER => 'User', - NS_USER_TALK => 'User_talk', - NS_PROJECT => 'Project', - NS_PROJECT_TALK => 'Project_talk', - NS_FILE => 'File', - NS_FILE_TALK => 'File_talk', - NS_MEDIAWIKI => 'MediaWiki', - NS_MEDIAWIKI_TALK => 'MediaWiki_talk', - NS_TEMPLATE => 'Template', - NS_TEMPLATE_TALK => 'Template_talk', - NS_HELP => 'Help', - NS_HELP_TALK => 'Help_talk', - NS_CATEGORY => 'Category', - NS_CATEGORY_TALK => 'Category_talk', -]; +$wgCanonicalNamespaceNames = NamespaceInfo::$canonicalNames; /// @todo UGLY UGLY if ( is_array( $wgExtraNamespaces ) ) { @@ -579,12 +542,6 @@ if ( isset( $wgSquidMaxage ) ) { $wgSquidMaxage = $wgCdnMaxAge; } -// Easy to forget to falsify $wgDebugToolbar for static caches. -// If file cache or CDN cache is on, just disable this (DWIMD). -if ( $wgUseFileCache || $wgUseCdn ) { - $wgDebugToolbar = false; -} - // Blacklisted file extensions shouldn't appear on the "allowed" list $wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) ); @@ -622,6 +579,11 @@ if ( $wgCookieSecure === 'detect' ) { } if ( $wgProfileOnly ) { + // Hard deprecated in 1.34. + wfDeprecated( + '$wgProfileOnly set the log file in $wgDebugLogGroups[\'profileoutput\'] instead', + '1.23' + ); $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile; $wgDebugLogFile = ''; } @@ -644,17 +606,11 @@ if ( $wgPHPSessionHandling !== 'enable' && if ( defined( 'MW_NO_SESSION' ) ) { // If the entry point wants no session, force 'disable' here unless they // specifically set it to the (undocumented) 'warn'. + // @phan-suppress-next-line PhanUndeclaredConstant $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable'; } -Profiler::instance()->scopedProfileOut( $ps_default ); - -// Disable MWDebug for command line mode, this prevents MWDebug from eating up -// all the memory from logging SQL queries on maintenance scripts -global $wgCommandLineMode; -if ( $wgDebugToolbar && !$wgCommandLineMode ) { - MWDebug::init(); -} +MWDebug::setup(); // Reset the global service locator, so any services that have already been created will be // re-created while taking into account any custom settings and extensions. @@ -678,8 +634,6 @@ foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) { } } -$ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' ); - if ( $wgCanonicalServer === false ) { $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP ); } @@ -749,10 +703,6 @@ if ( $wgSharedDB && $wgSharedTables ) { ); } -Profiler::instance()->scopedProfileOut( $ps_default2 ); - -$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' ); - // Raise the memory limit if it's too low // Note, this makes use of wfDebug, and thus should not be before // MWDebug::init() is called. @@ -824,21 +774,9 @@ if ( $wgCommandLineMode ) { $wgMemc = ObjectCache::getLocalClusterInstance(); $messageMemc = wfGetMessageCacheStorage(); -wfDebugLog( 'caches', - 'cluster: ' . get_class( $wgMemc ) . - ', WAN: ' . ( $wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache ) . - ', stash: ' . $wgMainStash . - ', message: ' . get_class( $messageMemc ) . - ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) ) -); - -Profiler::instance()->scopedProfileOut( $ps_misc ); - // Most of the config is out, some might want to run hooks here. Hooks::run( 'SetupAfterCache' ); -$ps_globals = Profiler::instance()->scopedProfileIn( $fname . '-globals' ); - /** * @var Language $wgContLang * @deprecated since 1.32, use the ContentLanguage service directly @@ -948,9 +886,6 @@ $wgParser = new StubObject( 'wgParser', function () { */ $wgTitle = null; -Profiler::instance()->scopedProfileOut( $ps_globals ); -$ps_extensions = Profiler::instance()->scopedProfileIn( $fname . '-extensions' ); - // Extension setup functions // Entries should be added to this variable during the inclusion // of the extension file. This allows the extension to perform @@ -983,6 +918,3 @@ if ( !$wgCommandLineMode ) { } $wgFullyInitialised = true; - -Profiler::instance()->scopedProfileOut( $ps_extensions ); -Profiler::instance()->scopedProfileOut( $ps_setup );