// Start the autoloader, so that extensions can derive classes from core files
require_once "$IP/includes/AutoLoader.php";
-// Load up some global defines
+// Load global constants
require_once "$IP/includes/Defines.php";
// Load default settings
die( 1 );
}
+/**
+ * Changes to the PHP environment that don't vary on configuration.
+ */
+
// Install a header callback
MediaWiki\HeaderCallback::register();
+// 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' );
+
/**
* Load LocalSettings.php
*/
* Main setup
*/
-$fname = 'Setup.php';
-$ps_setup = Profiler::instance()->scopedProfileIn( $fname );
-
// Load queued extensions
ExtensionRegistry::getInstance()->loadFromQueue();
// Don't let any other extensions load
ExtensionRegistry::getInstance()->finish();
-mb_internal_encoding( 'UTF-8' );
-
// Set the configured locale on all requests for consisteny
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";
}
if ( $wgLoadScript === false ) {
$wgLoadScript = "$wgScriptPath/load.php";
}
+if ( $wgRestPath === false ) {
+ $wgRestPath = "$wgScriptPath/rest.php";
+}
if ( $wgArticlePath === false ) {
if ( $wgUsePathInfo ) {
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'],
unset( $rcMaxAgeDays );
if ( $wgSkipSkin ) {
+ // Hard deprecated in 1.34.
+ wfDeprecated( '$wgSkipSkin – use $wgSkipSkins instead', '1.23' );
$wgSkipSkins[] = $wgSkipSkin;
}
$wgSkipSkins[] = 'apioutput';
if ( $wgLocalInterwiki ) {
+ // Hard deprecated in 1.34.
+ wfDeprecated( '$wgLocalInterwiki – use $wgLocalInterwikis instead', '1.23' );
array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
}
* 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 ) ) {
// To determine the user language, use $wgLang->getCode()
$wgContLanguageCode = $wgLanguageCode;
-// Easy to forget to falsify $wgDebugToolbar for static caches.
-// If file cache or CDN cache is on, just disable this (DWIMD).
-if ( $wgUseFileCache || $wgUseSquid ) {
- $wgDebugToolbar = false;
+// Temporary backwards-compatibility reading of old Squid-named CDN settings as of MediaWiki 1.34,
+// to support sysadmins who fail to update their settings immediately:
+
+if ( isset( $wgUseSquid ) ) {
+ // If the sysadmin is still setting a value of $wgUseSquid to true but $wgUseCdn is the default of
+ // false, to be safe, assume they do want this still, so enable it.
+ if ( !$wgUseCdn && $wgUseSquid ) {
+ $wgUseCdn = $wgUseSquid;
+ wfDeprecated( '$wgUseSquid enabled but $wgUseCdn disabled; enabling CDN functions', '1.34' );
+ }
+} else {
+ // Backwards-compatibility for extensions that read this value.
+ $wgUseSquid = $wgUseCdn;
+}
+
+if ( isset( $wgSquidServers ) ) {
+ // If the sysadmin is still setting a value of $wgSquidServers but $wgCdnServers is the default of
+ // empty, to be safe, assume they do want these servers to be still used, so use them.
+ if ( !empty( $wgSquidServers ) && empty( $wgCdnServers ) ) {
+ $wgCdnServers = $wgSquidServers;
+ wfDeprecated( '$wgSquidServers set, $wgCdnServers empty; using them', '1.34' );
+ }
+} else {
+ // Backwards-compatibility for extensions that read this value.
+ $wgSquidServers = $wgCdnServers;
}
-// We always output HTML5 since 1.22, overriding these is no longer supported
-// we set them here for extensions that depend on its value.
-$wgHtml5 = true;
-$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
-$wgJsMimeType = 'text/javascript';
+if ( isset( $wgSquidServersNoPurge ) ) {
+ // If the sysadmin is still setting values in $wgSquidServersNoPurge but $wgCdnServersNoPurge is
+ // the default of empty, to be safe, assume they do want these servers to be still used, so use
+ // them.
+ if ( !empty( $wgSquidServersNoPurge ) && empty( $wgCdnServersNoPurge ) ) {
+ $wgCdnServersNoPurge = $wgSquidServersNoPurge;
+ wfDeprecated( '$wgSquidServersNoPurge set, $wgCdnServersNoPurge empty; using them', '1.34' );
+ }
+} else {
+ // Backwards-compatibility for extensions that read this value.
+ $wgSquidServersNoPurge = $wgCdnServersNoPurge;
+}
+
+if ( isset( $wgSquidMaxage ) ) {
+ // If the sysadmin is still setting a value of $wgSquidMaxage and it's higher than $wgCdnMaxAge,
+ // to be safe, assume they want the higher (lower performance requirement) value, so use that.
+ if ( $wgCdnMaxAge < $wgSquidMaxage ) {
+ $wgCdnMaxAge = $wgSquidMaxage;
+ wfDeprecated( '$wgSquidMaxage set higher than $wgCdnMaxAge; using the higher value', '1.34' );
+ }
+} else {
+ // Backwards-compatibility for extensions that read this value.
+ $wgSquidMaxage = $wgCdnMaxAge;
+}
// Blacklisted file extensions shouldn't appear on the "allowed" list
$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) );
}
if ( $wgProfileOnly ) {
+ // Hard deprecated in 1.34.
+ wfDeprecated(
+ '$wgProfileOnly set the log file in $wgDebugLogGroups[\'profileoutput\'] instead',
+ '1.23'
+ );
$wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
$wgDebugLogFile = '';
}
$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.
MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' );
-if ( $wgSharedDB && $wgSharedTables ) {
- // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
- MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
- array_fill_keys(
- $wgSharedTables,
- [
- 'dbname' => $wgSharedDB,
- 'schema' => $wgSharedSchema,
- 'prefix' => $wgSharedPrefix
- ]
- )
- );
-}
-
// Define a constant that indicates that the bootstrapping of the service locator
// is complete.
define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
}
}
-$ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' );
-
if ( $wgCanonicalServer === false ) {
$wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
}
];
}
-Profiler::instance()->scopedProfileOut( $ps_default2 );
-
-$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' );
+if ( $wgSharedDB && $wgSharedTables ) {
+ // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
+ MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
+ array_fill_keys(
+ $wgSharedTables,
+ [
+ 'dbname' => $wgSharedDB,
+ 'schema' => $wgSharedSchema,
+ 'prefix' => $wgSharedPrefix
+ ]
+ )
+ );
+}
// Raise the memory limit if it's too low
-wfMemoryLimit();
+// Note, this makes use of wfDebug, and thus should not be before
+// MWDebug::init() is called.
+wfMemoryLimit( $wgMemoryLimit );
/**
* Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
// Useful debug output
if ( $wgCommandLineMode ) {
- wfDebug( "\n\nStart command line script $self\n" );
+ if ( isset( $self ) ) {
+ wfDebug( "\n\nStart command line script $self\n" );
+ }
} else {
$debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
-
- if ( $wgDebugPrintHttpHeaders ) {
- $debug .= "HTTP HEADERS:\n";
-
- foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
- $debug .= "$name: $value\n";
- }
+ $debug .= "HTTP HEADERS:\n";
+ foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
+ $debug .= "$name: $value\n";
}
wfDebug( $debug );
}
', 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
*/
$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
}
$wgFullyInitialised = true;
-
-Profiler::instance()->scopedProfileOut( $ps_extensions );
-Profiler::instance()->scopedProfileOut( $ps_setup );