MediaWiki REL1_33
Setup.php
Go to the documentation of this file.
1<?php
29
34if ( !defined( 'MEDIAWIKI' ) ) {
35 exit( 1 );
36}
37
38// Check to see if we are at the file scope
39$wgScopeTest = 'MediaWiki Setup.php scope test';
40if ( !isset( $GLOBALS['wgScopeTest'] ) || $GLOBALS['wgScopeTest'] !== $wgScopeTest ) {
41 echo "Error, Setup.php must be included from the file scope.\n";
42 die( 1 );
43}
45
50// Sanity check (T5782, T122807)
51if ( ini_get( 'mbstring.func_overload' ) ) {
52 die( 'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
53}
54
55// Start the autoloader, so that extensions can derive classes from core files
56require_once "$IP/includes/AutoLoader.php";
57
58// Load up some global defines
59require_once "$IP/includes/Defines.php";
60
61// Load default settings
62require_once "$IP/includes/DefaultSettings.php";
63
64// Load global functions
65require_once "$IP/includes/GlobalFunctions.php";
66
67// Load composer's autoloader if present
68if ( is_readable( "$IP/vendor/autoload.php" ) ) {
69 require_once "$IP/vendor/autoload.php";
70} elseif ( file_exists( "$IP/vendor/autoload.php" ) ) {
71 die( "$IP/vendor/autoload.php exists but is not readable" );
72}
73
74// Assert that composer dependencies were successfully loaded
75// Purposely no leading \ due to it breaking HHVM RepoAuthorative mode
76// PHP works fine with both versions
77// See https://github.com/facebook/hhvm/issues/5833
78if ( !interface_exists( 'Psr\Log\LoggerInterface' ) ) {
79 $message = (
80 'MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging ' .
81 "library</a> to be present. This library is not embedded directly in MediaWiki's " .
82 "git repository and must be installed separately by the end user.\n\n" .
83 'Please see <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
84 '#Fetch_external_libraries">mediawiki.org</a> for help on installing ' .
85 'the required components.'
86 );
87 echo $message;
88 trigger_error( $message, E_USER_ERROR );
89 die( 1 );
90}
91
92// Install a header callback
93MediaWiki\HeaderCallback::register();
94
99if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
101} else {
102 if ( !defined( 'MW_CONFIG_FILE' ) ) {
103 define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" );
104 }
105 require_once MW_CONFIG_FILE;
106}
107
115if ( defined( 'MW_SETUP_CALLBACK' ) ) {
116 call_user_func( MW_SETUP_CALLBACK );
117}
118
123$fname = 'Setup.php';
124$ps_setup = Profiler::instance()->scopedProfileIn( $fname );
125
126// Load queued extensions
127ExtensionRegistry::getInstance()->loadFromQueue();
128// Don't let any other extensions load
130
131mb_internal_encoding( 'UTF-8' );
132
133// Set the configured locale on all requests for consisteny
134putenv( "LC_ALL=$wgShellLocale" );
135setlocale( LC_ALL, $wgShellLocale );
136
137// Set various default paths sensibly...
138$ps_default = Profiler::instance()->scopedProfileIn( $fname . '-defaults' );
139
140if ( $wgScript === false ) {
141 $wgScript = "$wgScriptPath/index.php";
142}
143if ( $wgLoadScript === false ) {
144 $wgLoadScript = "$wgScriptPath/load.php";
145}
146
147if ( $wgArticlePath === false ) {
148 if ( $wgUsePathInfo ) {
149 $wgArticlePath = "$wgScript/$1";
150 } else {
151 $wgArticlePath = "$wgScript?title=$1";
152 }
153}
154
155if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
156 // 'view' is assumed the default action path everywhere in the code
157 // but is rarely filled in $wgActionPaths
159}
160
161if ( $wgResourceBasePath === null ) {
163}
164if ( $wgStylePath === false ) {
165 $wgStylePath = "$wgResourceBasePath/skins";
166}
167if ( $wgLocalStylePath === false ) {
168 // Avoid wgResourceBasePath here since that may point to a different domain (e.g. CDN)
169 $wgLocalStylePath = "$wgScriptPath/skins";
170}
171if ( $wgExtensionAssetsPath === false ) {
172 $wgExtensionAssetsPath = "$wgResourceBasePath/extensions";
173}
174
175if ( $wgLogo === false ) {
176 $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";
177}
178
179if ( $wgUploadPath === false ) {
180 $wgUploadPath = "$wgScriptPath/images";
181}
182if ( $wgUploadDirectory === false ) {
183 $wgUploadDirectory = "$IP/images";
184}
185if ( $wgReadOnlyFile === false ) {
186 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
187}
188if ( $wgFileCacheDirectory === false ) {
189 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
190}
191if ( $wgDeletedDirectory === false ) {
192 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
193}
194
195if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
196 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
197}
198
199// Fix path to icon images after they were moved in 1.24
200if ( $wgRightsIcon ) {
202 "{$wgStylePath}/common/images/",
203 "{$wgResourceBasePath}/resources/assets/licenses/",
205 );
206}
207
208if ( isset( $wgFooterIcons['copyright']['copyright'] )
209 && $wgFooterIcons['copyright']['copyright'] === []
210) {
211 if ( $wgRightsIcon || $wgRightsText ) {
212 $wgFooterIcons['copyright']['copyright'] = [
213 'url' => $wgRightsUrl,
214 'src' => $wgRightsIcon,
215 'alt' => $wgRightsText,
216 ];
217 }
218}
219
220if ( isset( $wgFooterIcons['poweredby'] )
221 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
222 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
223) {
224 $wgFooterIcons['poweredby']['mediawiki']['src'] =
225 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
226 $wgFooterIcons['poweredby']['mediawiki']['srcset'] =
227 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
228 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
229}
230
239
247
252 'name' => 'fsLockManager',
253 'class' => FSLockManager::class,
254 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
255];
256$wgLockManagers[] = [
257 'name' => 'nullLockManager',
258 'class' => NullLockManager::class,
259];
260
266 'imagesPerRow' => 0,
267 'imageWidth' => 120,
268 'imageHeight' => 120,
269 'captionLength' => true,
270 'showBytes' => true,
271 'showDimensions' => true,
272 'mode' => 'traditional',
273];
274
278if ( !$wgLocalFileRepo ) {
280 'class' => LocalRepo::class,
281 'name' => 'local',
282 'directory' => $wgUploadDirectory,
283 'scriptDirUrl' => $wgScriptPath,
285 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
286 'thumbScriptUrl' => $wgThumbnailScriptPath,
287 'transformVia404' => !$wgGenerateThumbnailOnParse,
288 'deletedDir' => $wgDeletedDirectory,
289 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0
290 ];
291}
292
293if ( !isset( $wgLocalFileRepo['backend'] ) ) {
294 // Create a default FileBackend name.
295 // FileBackendGroup will register a default, if absent from $wgFileBackends.
296 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
297}
298
302if ( $wgUseSharedUploads ) {
303 if ( $wgSharedUploadDBname ) {
305 'class' => ForeignDBRepo::class,
306 'name' => 'shared',
307 'directory' => $wgSharedUploadDirectory,
308 'url' => $wgSharedUploadPath,
309 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
310 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
311 'transformVia404' => !$wgGenerateThumbnailOnParse,
312 'dbType' => $wgDBtype,
313 'dbServer' => $wgDBserver,
314 'dbUser' => $wgDBuser,
315 'dbPassword' => $wgDBpassword,
316 'dbName' => $wgSharedUploadDBname,
317 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
318 'tablePrefix' => $wgSharedUploadDBprefix,
319 'hasSharedCache' => $wgCacheSharedUploads,
320 'descBaseUrl' => $wgRepositoryBaseUrl,
321 'fetchDescription' => $wgFetchCommonsDescriptions,
322 ];
323 } else {
325 'class' => FileRepo::class,
326 'name' => 'shared',
327 'directory' => $wgSharedUploadDirectory,
328 'url' => $wgSharedUploadPath,
329 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
330 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
331 'transformVia404' => !$wgGenerateThumbnailOnParse,
332 'descBaseUrl' => $wgRepositoryBaseUrl,
333 'fetchDescription' => $wgFetchCommonsDescriptions,
334 ];
335 }
336}
339 'class' => ForeignAPIRepo::class,
340 'name' => 'wikimediacommons',
341 'apibase' => 'https://commons.wikimedia.org/w/api.php',
342 'url' => 'https://upload.wikimedia.org/wikipedia/commons',
343 'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
344 'hashLevels' => 2,
345 'transformVia404' => true,
346 'fetchDescription' => true,
347 'descriptionCacheExpiry' => 43200,
348 'apiThumbCacheExpiry' => 0,
349 ];
350}
351foreach ( $wgForeignFileRepos as &$repo ) {
352 if ( !isset( $repo['directory'] ) && $repo['class'] === ForeignAPIRepo::class ) {
353 $repo['directory'] = $wgUploadDirectory; // b/c
354 }
355 if ( !isset( $repo['backend'] ) ) {
356 $repo['backend'] = $repo['name'] . '-backend';
357 }
358}
359unset( $repo ); // no global pollution; destroy reference
360
361$rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
362if ( $wgRCFilterByAge ) {
363 // Trim down $wgRCLinkDays so that it only lists links which are valid
364 // as determined by $wgRCMaxAge.
365 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
367
368 foreach ( $wgRCLinkDays as $i => $days ) {
369 if ( $days >= $rcMaxAgeDays ) {
370 array_splice( $wgRCLinkDays, $i + 1 );
371 break;
372 }
373 }
374}
375// Ensure that default user options are not invalid, since that breaks Special:Preferences
376$wgDefaultUserOptions['rcdays'] = min(
377 $wgDefaultUserOptions['rcdays'],
379);
380$wgDefaultUserOptions['watchlistdays'] = min(
381 $wgDefaultUserOptions['watchlistdays'],
383);
385
386if ( $wgSkipSkin ) {
388}
389
390$wgSkipSkins[] = 'fallback';
391$wgSkipSkins[] = 'apioutput';
392
393if ( $wgLocalInterwiki ) {
395}
396
397// Set default shared prefix
398if ( $wgSharedPrefix === false ) {
400}
401
402// Set default shared schema
403if ( $wgSharedSchema === false ) {
405}
406
407if ( !$wgCookiePrefix ) {
408 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
410 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
412 } elseif ( $wgDBprefix ) {
414 } else {
416 }
417}
418$wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
419
420if ( $wgEnableEmail ) {
422} else {
423 // Disable all other email settings automatically if $wgEnableEmail
424 // is set to false. - T65678
425 $wgAllowHTMLEmail = false;
426 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
436 unset( $wgGroupPermissions['user']['sendemail'] );
440}
441
442if ( $wgMetaNamespace === false ) {
444}
445
446// Default value is 2000 or the suhosin limit if it is between 1 and 2000
447if ( $wgResourceLoaderMaxQueryLength === false ) {
448 $suhosinMaxValueLength = (int)ini_get( 'suhosin.get.max_value_length' );
449 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
451 } else {
453 }
454 unset( $suhosinMaxValueLength );
455}
456
457// Ensure the minimum chunk size is less than PHP upload limits or the maximum
458// upload size.
464 ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ),
465 PHP_INT_MAX
466 ) ?: PHP_INT_MAX ) - 1024 // Leave some room for other POST parameters
467);
468
474 NS_MEDIA => 'Media',
475 NS_SPECIAL => 'Special',
476 NS_TALK => 'Talk',
477 NS_USER => 'User',
478 NS_USER_TALK => 'User_talk',
479 NS_PROJECT => 'Project',
480 NS_PROJECT_TALK => 'Project_talk',
481 NS_FILE => 'File',
482 NS_FILE_TALK => 'File_talk',
483 NS_MEDIAWIKI => 'MediaWiki',
484 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
485 NS_TEMPLATE => 'Template',
486 NS_TEMPLATE_TALK => 'Template_talk',
487 NS_HELP => 'Help',
488 NS_HELP_TALK => 'Help_talk',
489 NS_CATEGORY => 'Category',
490 NS_CATEGORY_TALK => 'Category_talk',
491];
492
496}
497
498// Hard-deprecate setting $wgDummyLanguageCodes in LocalSettings.php
499if ( count( $wgDummyLanguageCodes ) !== 0 ) {
500 wfDeprecated( '$wgDummyLanguageCodes', '1.29' );
501}
502// Merge in the legacy language codes, incorporating overrides from the config
504 // Internal language codes of the private-use area which get mapped to
505 // themselves.
506 'qqq' => 'qqq', // Used for message documentation
507 'qqx' => 'qqx', // Used for viewing message keys
508] + $wgExtraLanguageCodes + LanguageCode::getDeprecatedCodeMapping();
509// Merge in (inverted) BCP 47 mappings
510foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 ) {
511 $bcp47 = strtolower( $bcp47 ); // force case-insensitivity
512 if ( !isset( $wgDummyLanguageCodes[$bcp47] ) ) {
514 }
515}
516
517// These are now the same, always
518// To determine the user language, use $wgLang->getCode()
520
521// Easy to forget to falsify $wgDebugToolbar for static caches.
522// If file cache or CDN cache is on, just disable this (DWIMD).
524 $wgDebugToolbar = false;
525}
526
527// We always output HTML5 since 1.22, overriding these is no longer supported
528// we set them here for extensions that depend on its value.
529$wgHtml5 = true;
530$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
531$wgJsMimeType = 'text/javascript';
532
533// Blacklisted file extensions shouldn't appear on the "allowed" list
535
538 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( "$IP/LocalSettings.php" ) ) );
540}
541
542if ( $wgNewUserLog ) {
543 // Add new user log type
544 $wgLogTypes[] = 'newusers';
545 $wgLogNames['newusers'] = 'newuserlogpage';
546 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
547 $wgLogActionsHandlers['newusers/newusers'] = NewUsersLogFormatter::class;
548 $wgLogActionsHandlers['newusers/create'] = NewUsersLogFormatter::class;
549 $wgLogActionsHandlers['newusers/create2'] = NewUsersLogFormatter::class;
550 $wgLogActionsHandlers['newusers/byemail'] = NewUsersLogFormatter::class;
551 $wgLogActionsHandlers['newusers/autocreate'] = NewUsersLogFormatter::class;
552}
553
554if ( $wgPageCreationLog ) {
555 // Add page creation log type
556 $wgLogTypes[] = 'create';
557 $wgLogActionsHandlers['create/create'] = LogFormatter::class;
558}
559
561 $wgLogTypes[] = 'pagelang';
562 $wgLogActionsHandlers['pagelang/pagelang'] = PageLangLogFormatter::class;
563}
564
565if ( $wgCookieSecure === 'detect' ) {
567}
568
569if ( $wgProfileOnly ) {
570 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
571 $wgDebugLogFile = '';
572}
573
574// Backwards compatibility with old password limits
575if ( $wgMinimalPasswordLength !== false ) {
576 $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength;
577}
578
579if ( $wgMaximalPasswordLength !== false ) {
580 $wgPasswordPolicy['policies']['default']['MaximalPasswordLength'] = $wgMaximalPasswordLength;
581}
582
583if ( $wgPHPSessionHandling !== 'enable' &&
584 $wgPHPSessionHandling !== 'warn' &&
585 $wgPHPSessionHandling !== 'disable'
586) {
587 $wgPHPSessionHandling = 'warn';
588}
589if ( defined( 'MW_NO_SESSION' ) ) {
590 // If the entry point wants no session, force 'disable' here unless they
591 // specifically set it to the (undocumented) 'warn'.
592 $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
593}
594
595Profiler::instance()->scopedProfileOut( $ps_default );
596
597// Disable MWDebug for command line mode, this prevents MWDebug from eating up
598// all the memory from logging SQL queries on maintenance scripts
601 MWDebug::init();
602}
603
604// Reset the global service locator, so any services that have already been created will be
605// re-created while taking into account any custom settings and extensions.
606MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' );
607
609 // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
610 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
613 [
614 'dbname' => $wgSharedDB,
615 'schema' => $wgSharedSchema,
616 'prefix' => $wgSharedPrefix
617 ]
618 )
619 );
620}
621
622// Define a constant that indicates that the bootstrapping of the service locator
623// is complete.
624define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
625
626MWExceptionHandler::installHandler();
627
628// T48998: Bail out early if $wgArticlePath is non-absolute
629foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) {
630 if ( $$varName && !preg_match( '/^(https?:\/\/|\/)/', $$varName ) ) {
631 throw new FatalError(
632 "If you use a relative URL for \$$varName, it must start " .
633 'with a slash (<code>/</code>).<br><br>See ' .
634 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
635 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
636 );
637 }
638}
639
640$ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' );
641
642if ( $wgCanonicalServer === false ) {
644}
645
646// Set server name
648if ( $wgServerName !== false ) {
649 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
650 . 'not customized. Overwriting $wgServerName.' );
651}
654
655// Set defaults for configuration variables
656// that are derived from the server name by default
657// Note: $wgEmergencyContact and $wgPasswordSender may be false or empty string (T104142)
658if ( !$wgEmergencyContact ) {
659 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
660}
661if ( !$wgPasswordSender ) {
662 $wgPasswordSender = 'apache@' . $wgServerName;
663}
664if ( !$wgNoReplyAddress ) {
666}
667
668if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
669 $wgSecureLogin = false;
670 wfWarn( 'Secure login was enabled on a server that only supports '
671 . 'HTTP or HTTPS. Disabling secure login.' );
672}
673
675
676// Now that GlobalFunctions is loaded, set defaults that depend on it.
677if ( $wgTmpDirectory === false ) {
679}
680
681// We don't use counters anymore. Left here for extensions still
682// expecting this to exist. Should be removed sometime 1.26 or later.
683if ( !isset( $wgDisableCounters ) ) {
684 $wgDisableCounters = true;
685}
686
687if ( $wgMainWANCache === false ) {
688 // Setup a WAN cache from $wgMainCacheType with no relayer.
689 // Sites using multiple datacenters can configure a relayer.
690 $wgMainWANCache = 'mediawiki-main-default';
692 'class' => WANObjectCache::class,
693 'cacheId' => $wgMainCacheType
694 ];
695}
696
697Profiler::instance()->scopedProfileOut( $ps_default2 );
698
699$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' );
700
701// Raise the memory limit if it's too low
703
709if ( is_null( $wgLocaltimezone ) ) {
713}
714
716if ( is_null( $wgLocalTZoffset ) ) {
717 $wgLocalTZoffset = date( 'Z' ) / 60;
718}
719// The part after the System| is ignored, but rest of MW fills it
720// out as the local offset.
721$wgDefaultUserOptions['timecorrection'] = "System|$wgLocalTZoffset";
722
723if ( !$wgDBerrorLogTZ ) {
725}
726
727// Initialize the request object in $wgRequest
728$wgRequest = RequestContext::getMain()->getRequest(); // BackCompat
729// Set user IP/agent information for agent session consistency purposes
730$cpPosInfo = LBFactory::getCPInfoFromCookieValue(
731 // The cookie has no prefix and is set by MediaWiki::preOutputCommit()
732 $wgRequest->getCookie( 'cpPosIndex', '' ),
733 // Mitigate broken client-side cookie expiration handling (T190082)
734 time() - ChronologyProtector::POSITION_COOKIE_TTL
735);
736MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
737 'IPAddress' => $wgRequest->getIP(),
738 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ),
739 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' ),
740 'ChronologyPositionIndex' => $wgRequest->getInt( 'cpPosIndex', $cpPosInfo['index'] ),
741 'ChronologyClientId' => $cpPosInfo['clientId']
742] );
744// Make sure that object caching does not undermine the ChronologyProtector improvements
745if ( $wgRequest->getCookie( 'UseDC', '' ) === 'master' ) {
746 // The user is pinned to the primary DC, meaning that they made recent changes which should
747 // be reflected in their subsequent web requests. Avoid the use of interim cache keys because
748 // they use a blind TTL and could be stale if an object changes twice in a short time span.
749 MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching( false );
750}
751
752// Useful debug output
753if ( $wgCommandLineMode ) {
754 wfDebug( "\n\nStart command line script $self\n" );
755} else {
756 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
757
759 $debug .= "HTTP HEADERS:\n";
760
761 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
762 $debug .= "$name: $value\n";
763 }
764 }
765 wfDebug( $debug );
766}
767
768$wgMemc = ObjectCache::getLocalClusterInstance();
770
771wfDebugLog( 'caches',
772 'cluster: ' . get_class( $wgMemc ) .
773 ', WAN: ' . ( $wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache ) .
774 ', stash: ' . $wgMainStash .
775 ', message: ' . get_class( $messageMemc ) .
776 ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) )
777);
778
779Profiler::instance()->scopedProfileOut( $ps_misc );
780
781// Most of the config is out, some might want to run hooks here.
782Hooks::run( 'SetupAfterCache' );
783
784$ps_globals = Profiler::instance()->scopedProfileIn( $fname . '-globals' );
785
790$wgContLang = MediaWikiServices::getInstance()->getContentLanguage();
791
792// Now that variant lists may be available...
793$wgRequest->interpolateTitle();
794
800if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
801 // If session.auto_start is there, we can't touch session name
802 if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ) {
804 }
805
806 // Create the SessionManager singleton and set up our session handler,
807 // unless we're specifically asked not to.
808 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
809 MediaWiki\Session\PHPSessionHandler::install(
810 MediaWiki\Session\SessionManager::singleton()
811 );
812 }
813
814 // Initialize the session
815 try {
816 $session = MediaWiki\Session\SessionManager::getGlobalSession();
817 } catch ( OverflowException $ex ) {
818 if ( isset( $ex->sessionInfos ) && count( $ex->sessionInfos ) >= 2 ) {
819 // The exception is because the request had multiple possible
820 // sessions tied for top priority. Report this to the user.
821 $list = [];
822 foreach ( $ex->sessionInfos as $info ) {
823 $list[] = $info->getProvider()->describe( $wgContLang );
824 }
825 $list = $wgContLang->listToText( $list );
826 throw new HttpError( 400,
827 Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $wgContLang )->plain()
828 );
829 }
830
831 // Not the one we want, rethrow
832 throw $ex;
833 }
834
835 if ( $session->isPersistent() ) {
836 $wgInitialSessionId = $session->getSessionId();
837 }
838
839 $session->renew();
840 if ( MediaWiki\Session\PHPSessionHandler::isEnabled() &&
841 ( $session->isPersistent() || $session->shouldRememberUser() ) &&
842 session_id() !== $session->getId()
843 ) {
844 // Start the PHP-session for backwards compatibility
845 if ( session_id() !== '' ) {
846 wfDebugLog( 'session', 'PHP session {old_id} was already started, changing to {new_id}', 'all', [
847 'old_id' => session_id(),
848 'new_id' => $session->getId(),
849 ] );
851 }
852 session_id( $session->getId() );
854 }
855
856 unset( $session );
857} else {
858 // Even if we didn't set up a global Session, still install our session
859 // handler unless specifically requested not to.
860 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
861 MediaWiki\Session\PHPSessionHandler::install(
862 MediaWiki\Session\SessionManager::singleton()
863 );
864 }
865}
866
870$wgUser = RequestContext::getMain()->getUser(); // BackCompat
871
876
880$wgOut = RequestContext::getMain()->getOutput(); // BackCompat
881
886$wgParser = new StubObject( 'wgParser', function () {
887 return MediaWikiServices::getInstance()->getParser();
888} );
889
893$wgTitle = null;
894
895Profiler::instance()->scopedProfileOut( $ps_globals );
896$ps_extensions = Profiler::instance()->scopedProfileIn( $fname . '-extensions' );
897
898// Extension setup functions
899// Entries should be added to this variable during the inclusion
900// of the extension file. This allows the extension to perform
901// any necessary initialisation in the fully initialised environment
902foreach ( $wgExtensionFunctions as $func ) {
903 call_user_func( $func );
904}
905
906// If the session user has a 0 id but a valid name, that means we need to
907// autocreate it.
908if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
909 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
910 if ( $sessionUser->getId() === 0 && User::isValidUserName( $sessionUser->getName() ) ) {
911 $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser(
912 $sessionUser,
913 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
914 true
915 );
916 \MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [
917 'event' => 'autocreate',
918 'status' => $res,
919 ] );
920 unset( $res );
921 }
922 unset( $sessionUser );
923}
924
925if ( !$wgCommandLineMode ) {
927}
928
930
931Profiler::instance()->scopedProfileOut( $ps_extensions );
932Profiler::instance()->scopedProfileOut( $ps_setup );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$GLOBALS['IP']
$wgRightsIcon
Override for copyright metadata.
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
bool $wgPageLanguageUseDB
Enable page language feature Allows setting page language in database.
string $wgSharedUploadDirectory
Shortcut for the 'directory' setting of $wgForeignFileRepos.
$wgUsePathInfo
Whether to support URLs like index.php/Page_title These often break when PHP is set up in CGI mode.
$wgLanguageCode
Site language code.
$wgEmergencyContact
Site admin email address.
$wgDBprefix
Table name prefix.
$wgDBuser
Database username.
string $wgPHPSessionHandling
Whether to use PHP session handling ($_SESSION and session_*() functions)
bool $wgCacheSharedUploads
Shortcut for the ForeignDBRepo 'hasSharedCache' setting in $wgForeignFileRepos.
bool string $wgSharedUploadDBname
Shortcut for the ForeignDBRepo 'dbName' setting in $wgForeignFileRepos.
$wgScript
The URL path to index.php.
$wgUseInstantCommons
Use Wikimedia Commons as a foreign file repository.
bool $wgHashedSharedUploadDirectory
Shortcut for the 'hashLevels' setting of $wgForeignFileRepos.
$wgCacheDirectory
Directory for caching data in the local filesystem.
$wgGenerateThumbnailOnParse
Allow thumbnail rendering on page view.
$wgRightsUrl
Set this to specify an external URL containing details about the content license used on your wiki.
$wgSharedTables
$wgSessionName
Override to customise the session name.
$wgLocalInterwiki
The interwiki prefix of the current wiki, or false if it doesn't have one.
$wgPasswordPolicy
Password policy for the wiki.
$wgLogNames
Lists the message key string for each log type.
$wgHashedUploadDirectory
Set this to false if you do not want MediaWiki to divide your images directory into many subdirectori...
$wgInvalidateCacheOnLocalSettingsChange
Invalidate various caches when LocalSettings.php changes.
$wgLocalStylePath
The URL path of the skins directory.
$wgThumbnailScriptPath
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating t...
$wgExtraNamespaces
Additional namespaces.
$wgTmpDirectory
The local filesystem path to a temporary directory.
bool $wgUseSharedUploads
Shortcut for adding an entry to $wgForeignFileRepos.
string $wgSharedUploadDBprefix
Shortcut for the ForeignDBRepo 'tablePrefix' setting in $wgForeignFileRepos.
$wgDBtype
Database type.
$wgDBmwschema
Mediawiki schema; this should be alphanumeric and not contain spaces nor hyphens.
$wgNoReplyAddress
Reply-To address for e-mail notifications.
$wgDBerrorLogTZ
Timezone to use in the error log.
$wgUploadDirectory
The filesystem path of the images directory.
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
$wgMaximalPasswordLength
Specifies the maximal length of a user password (T64685).
$wgSitename
Name of the site.
$wgReadOnlyFile
If this lock file exists (size > 0), the wiki will be forced into read-only mode.
$wgResourceLoaderMaxQueryLength
If set to a positive number, ResourceLoader will not generate URLs whose query string is more than th...
$wgFileCacheDirectory
Directory where the cached page will be saved.
$wgRightsText
If either $wgRightsUrl or $wgRightsPage is specified then this variable gives the text for the link.
$wgGitInfoCacheDirectory
Directory where GitInfo will look for pre-computed cache files.
$wgPageCreationLog
Maintain a log of page creations at Special:Log/create?
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
$wgProfileOnly
Don't put non-profiling info into log file.
$wgFooterIcons
Abstract list of footer icons for skins in place of old copyrightico and poweredbyico code You can ad...
$wgUploadPath
The URL path for the images directory.
$wgFileBlacklist
Files with these extensions will never be allowed as uploads.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
$wgExtensionFunctions
A list of callback functions which are called once MediaWiki is fully initialised.
$wgUseSquid
Enable/disable CDN.
$wgShellLocale
Locale for LC_ALL, to provide a known environment for locale-sensitive operations.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
$wgRCMaxAge
Recentchanges items are periodically purged; entries older than this many seconds will go.
$wgLocaltimezone
Fake out the timezone that the server thinks it's in.
$wgUploadBaseUrl
If set, this URL is added to the start of $wgUploadPath to form a complete upload URL.
bool $wgFetchCommonsDescriptions
Shortcut for the 'fetchDescription' setting of $wgForeignFileRepos.
string $wgSharedThumbnailScriptPath
Shortcut for the 'thumbScriptUrl' setting of $wgForeignFileRepos.
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
$wgLocalFileRepo
File repository structures.
$wgDeletedDirectory
What directory to place deleted uploads in.
$wgScriptPath
The path we should point to.
$wgWANObjectCaches
Advanced WAN object cache configuration.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
$wgMainStash
Main object stash type.
$wgExtensionAssetsPath
The URL path of the extensions directory.
$wgDebugToolbar
Display the new debugging toolbar.
$wgForeignFileRepos
Enable the use of files from one or more other wikis.
$wgRepositoryBaseUrl
Shortcut for the 'descBaseUrl' setting of $wgForeignFileRepos.
$wgLogHeaders
Lists the message key string for descriptive text to be shown at the top of each log type.
$wgDebugLogGroups
Map of string log group names to log destinations.
$wgSharedDB
Shared database for multiple wikis.
$wgSessionCacheType
The cache type for storing session data.
$wgDebugDumpSql
Write SQL queries to the debug log.
$wgDBserver
Database host name or IP address.
$wgLoadScript
The URL path to load.php.
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$wgExtraLanguageCodes
List of mappings from one language code to another.
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
$wgStylePath
The URL path of the skins directory.
$wgServer
URL of the server.
$wgRCFilterByAge
Filter $wgRCLinkDays by $wgRCMaxAge to avoid showing links for numbers higher than what will be store...
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
$wgMetaNamespace
Name of the project namespace.
$wgLogo
The URL path of the wiki logo.
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
$wgSharedSchema
$wgDebugLogFile
Filename for debug logging.
$wgPasswordSender
Sender email address for e-mail notifications.
$wgLogActionsHandlers
The same as above, but here values are names of classes, not messages.
string $wgSharedUploadPath
Shortcut for the 'url' setting of $wgForeignFileRepos.
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
$wgSharedPrefix
$wgMainWANCache
Main Wide-Area-Network cache type.
$wgDebugPrintHttpHeaders
Print HTTP headers for every request in the debug information.
$wgDBpassword
Database user's password.
$wgRCLinkDays
List of Days options to list in the Special:Recentchanges and Special:Recentchangeslinked pages.
$wgNewUserLog
Maintain a log of newusers at Special:Log/newusers?
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
wfTempDir()
Tries to get the system directory for temporary files.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
wfGetMessageCacheStorage()
Get the cache object used by the message cache.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfShorthandToInteger( $string='', $default=-1)
Converts shorthand byte notation to integer form.
wfMemoryLimit()
Set PHP's memory limit to the larger of php.ini or $wgMemoryLimit.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
$wgGroupPermissions['sysop']['replacetext']
$wgGalleryOptions
Default parameters for the "<gallery>" tag.
Definition Setup.php:265
$ps_extensions
Definition Setup.php:896
$messageMemc
Definition Setup.php:769
$wgFileExtensions
Definition Setup.php:534
if(is_array($wgExtraNamespaces)) if(count( $wgDummyLanguageCodes) !==0) $wgDummyLanguageCodes
Definition Setup.php:503
$wgEnotifWatchlist
Definition Setup.php:435
$wgContLang
Definition Setup.php:790
$wgEnotifMaxRecips
Definition Setup.php:430
$wgEnotifUserTalk
Definition Setup.php:434
$cpPosInfo
Definition Setup.php:730
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//' $wgVirtualRestConfig)['global']['domain']
Definition Setup.php:674
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
Definition Setup.php:376
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Definition Setup.php:123
$wgEnableUserEmail
Definition Setup.php:427
$rcMaxAgeDays
Definition Setup.php:361
if( $wgUseFileCache|| $wgUseSquid) $wgHtml5
Definition Setup.php:529
foreach(LanguageCode::getNonstandardLanguageCodeMapping() as $code=> $bcp47) $wgContLanguageCode
Definition Setup.php:519
$wgOut
Definition Setup.php:880
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
Definition Setup.php:473
$wgMemc
Definition Setup.php:768
$wgParser
Definition Setup.php:886
foreach([ 'wgArticlePath', 'wgVariantArticlePath'] as $varName) $ps_default2
Definition Setup.php:640
global $wgCommandLineMode
Definition Setup.php:599
foreach( $wgExtensionFunctions as $func) if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
Definition Setup.php:929
$wgTitle
Definition Setup.php:893
$wgEnotifFromEditor
Definition Setup.php:428
$wgJsMimeType
Definition Setup.php:531
$wgUseEnotif
Definition Setup.php:437
$wgEnotifRevealEditorAddress
Definition Setup.php:432
if(!defined( 'MEDIAWIKI')) $wgScopeTest
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:39
$wgInitialSessionId
Definition Setup.php:799
$wgEnotifImpersonal
Definition Setup.php:429
$wgUsersNotifiedOnAllChanges
Definition Setup.php:439
$wgUserEmailUseReplyTo
Definition Setup.php:438
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:728
if($wgScript===false) if( $wgLoadScript===false) if($wgArticlePath===false) if(!empty( $wgActionPaths) &&!isset( $wgActionPaths['view'])) if($wgResourceBasePath===null) if( $wgStylePath===false) if($wgLocalStylePath===false) if( $wgExtensionAssetsPath===false) if($wgLogo===false) if( $wgUploadPath===false) if($wgUploadDirectory===false) if( $wgReadOnlyFile===false) if($wgFileCacheDirectory===false) if( $wgDeletedDirectory===false) if($wgGitInfoCacheDirectory===false &&$wgCacheDirectory !==false) if( $wgRightsIcon) if(isset($wgFooterIcons $wgNamespaceProtection[ 'copyright'][ 'copyright']) &&$wgFooterIcons[ 'copyright'][ 'copyright']===[]) if(isset( $wgFooterIcons['poweredby']) &&isset( $wgFooterIcons['poweredby']['mediawiki']) && $wgFooterIcons['poweredby']['mediawiki']['src']===null)[NS_MEDIAWIKI]
Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a sysadmin to set $wgName...
Definition Setup.php:238
$ps_default
Definition Setup.php:138
if($wgLocalInterwiki) if( $wgSharedPrefix===false) if($wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
Definition Setup.php:418
if( $wgServerName !==false) $wgServerName
Definition Setup.php:652
$wgEnotifMinorEdits
Definition Setup.php:431
$ps_setup
Definition Setup.php:124
$ps_globals
Definition Setup.php:784
$wgXhtmlDefaultNamespace
Definition Setup.php:530
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
Definition Setup.php:251
$wgEmailAuthentication
Definition Setup.php:426
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
Definition Setup.php:245
$wgLang
Definition Setup.php:875
if( $wgCanonicalServer===false) $serverParts
Definition Setup.php:647
$ps_misc
Definition Setup.php:699
if( $wgSkipSkin) $wgSkipSkins[]
Definition Setup.php:390
$wgEnotifUseRealName
Definition Setup.php:433
if($wgMetaNamespace===false) if( $wgResourceLoaderMaxQueryLength===false) $wgMinUploadChunkSize
Definition Setup.php:459
Exception class which takes an HTML error message, and does not produce a backtrace.
Accesses configuration settings from $GLOBALS.
Show an error that looks like an HTTP server error.
Definition HttpError.php:30
MediaWikiServices is the service locator for the application scope of MediaWiki.
Functions to get cache objects.
static schedulePingback()
Schedule a deferred callable that will check if a pingback should be sent and (if so) proceed to send...
Definition Pingback.php:271
static instance()
Singleton.
Definition Profiler.php:62
static getMain()
Get the RequestContext object associated with the main request.
Class to implement stub globals, which are globals that delay loading the their associated module cod...
Stub object for the user language.
static getMaxUploadSize( $forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
static getMaxPhpUploadSize()
Get the PHP maximum uploaded file size, based on ini settings.
static isValidUserName( $name)
Is the input a valid username?
Definition User.php:993
static detectProtocol()
Detect the protocol from $_SERVER.
Class for ensuring a consistent ordering of events as seen by the user, despite replication.
An interface for generating database load balancers.
Definition LBFactory.php:39
$res
Definition database.txt:21
either a plain
Definition hooks.txt:2054
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition hooks.txt:856
const NS_HELP
Definition Defines.php:85
const NS_FILE
Definition Defines.php:79
const CACHE_NONE
Definition Defines.php:111
const NS_MEDIAWIKI_TALK
Definition Defines.php:82
const NS_PROJECT_TALK
Definition Defines.php:78
const NS_MEDIAWIKI
Definition Defines.php:81
const NS_TEMPLATE
Definition Defines.php:83
const NS_SPECIAL
Definition Defines.php:62
const NS_FILE_TALK
Definition Defines.php:80
const NS_HELP_TALK
Definition Defines.php:86
const NS_CATEGORY_TALK
Definition Defines.php:88
const PROTO_HTTP
Definition Defines.php:228
const NS_MEDIA
Definition Defines.php:61
const NS_TALK
Definition Defines.php:74
const NS_USER_TALK
Definition Defines.php:76
const NS_PROJECT
Definition Defines.php:77
const NS_CATEGORY
Definition Defines.php:87
const NS_TEMPLATE_TALK
Definition Defines.php:84
$wgActionPaths
Definition img_auth.php:47
$wgArticlePath
Definition img_auth.php:46
const MW_CONFIG_CALLBACK
Definition install.php:26
const MW_NO_SESSION
Definition load.php:29
$debug
Definition mcc.php:31
controlled by the following MediaWiki still creates a BagOStuff but calls it to it are no ops If the cache daemon can t be it should also disable itself fairly $wgDBname
CACHE_MEMCACHED $wgMainCacheType
Definition memcached.txt:63
A helper class for throttling authentication attempts.
const DBO_DEFAULT
Definition defines.php:13
const DBO_DEBUG
Definition defines.php:9