MediaWiki REL1_29
Setup.php
Go to the documentation of this file.
1<?php
27
32if ( !defined( 'MEDIAWIKI' ) ) {
33 exit( 1 );
34}
35
36$fname = 'Setup.php';
37$ps_setup = Profiler::instance()->scopedProfileIn( $fname );
38
39// Load queued extensions
40ExtensionRegistry::getInstance()->loadFromQueue();
41// Don't let any other extensions load
43
44// Check to see if we are at the file scope
45if ( !isset( $wgVersion ) ) {
46 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
47 die( 1 );
48}
49
50mb_internal_encoding( 'UTF-8' );
51
52// Set various default paths sensibly...
53$ps_default = Profiler::instance()->scopedProfileIn( $fname . '-defaults' );
54
55if ( $wgScript === false ) {
56 $wgScript = "$wgScriptPath/index.php";
57}
58if ( $wgLoadScript === false ) {
59 $wgLoadScript = "$wgScriptPath/load.php";
60}
61
62if ( $wgArticlePath === false ) {
63 if ( $wgUsePathInfo ) {
64 $wgArticlePath = "$wgScript/$1";
65 } else {
66 $wgArticlePath = "$wgScript?title=$1";
67 }
68}
69
70if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
71 // 'view' is assumed the default action path everywhere in the code
72 // but is rarely filled in $wgActionPaths
74}
75
76if ( $wgResourceBasePath === null ) {
78}
79if ( $wgStylePath === false ) {
80 $wgStylePath = "$wgResourceBasePath/skins";
81}
82if ( $wgLocalStylePath === false ) {
83 // Avoid wgResourceBasePath here since that may point to a different domain (e.g. CDN)
84 $wgLocalStylePath = "$wgScriptPath/skins";
85}
86if ( $wgExtensionAssetsPath === false ) {
87 $wgExtensionAssetsPath = "$wgResourceBasePath/extensions";
88}
89
90if ( $wgLogo === false ) {
91 $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";
92}
93
94if ( $wgUploadPath === false ) {
95 $wgUploadPath = "$wgScriptPath/images";
96}
97if ( $wgUploadDirectory === false ) {
98 $wgUploadDirectory = "$IP/images";
99}
100if ( $wgReadOnlyFile === false ) {
101 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
102}
103if ( $wgFileCacheDirectory === false ) {
104 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
105}
106if ( $wgDeletedDirectory === false ) {
107 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
108}
109
110if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
111 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
112}
113
114if ( $wgEnableParserCache === false ) {
116}
117
118// Fix path to icon images after they were moved in 1.24
119if ( $wgRightsIcon ) {
120 $wgRightsIcon = str_replace(
121 "{$wgStylePath}/common/images/",
122 "{$wgResourceBasePath}/resources/assets/licenses/",
124 );
125}
126
127if ( isset( $wgFooterIcons['copyright']['copyright'] )
128 && $wgFooterIcons['copyright']['copyright'] === []
129) {
130 if ( $wgRightsIcon || $wgRightsText ) {
131 $wgFooterIcons['copyright']['copyright'] = [
132 'url' => $wgRightsUrl,
133 'src' => $wgRightsIcon,
134 'alt' => $wgRightsText,
135 ];
136 }
137}
138
139if ( isset( $wgFooterIcons['poweredby'] )
140 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
141 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
142) {
143 $wgFooterIcons['poweredby']['mediawiki']['src'] =
144 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
145 $wgFooterIcons['poweredby']['mediawiki']['srcset'] =
146 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
147 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
148}
149
158
166
171 'name' => 'fsLockManager',
172 'class' => 'FSLockManager',
173 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
174];
175$wgLockManagers[] = [
176 'name' => 'nullLockManager',
177 'class' => 'NullLockManager',
178];
179
183if ( !$wgLocalFileRepo ) {
185 'class' => 'LocalRepo',
186 'name' => 'local',
187 'directory' => $wgUploadDirectory,
188 'scriptDirUrl' => $wgScriptPath,
189 'scriptExtension' => '.php',
191 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
192 'thumbScriptUrl' => $wgThumbnailScriptPath,
193 'transformVia404' => !$wgGenerateThumbnailOnParse,
194 'deletedDir' => $wgDeletedDirectory,
195 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0
196 ];
197}
201if ( $wgUseSharedUploads ) {
202 if ( $wgSharedUploadDBname ) {
204 'class' => 'ForeignDBRepo',
205 'name' => 'shared',
206 'directory' => $wgSharedUploadDirectory,
207 'url' => $wgSharedUploadPath,
208 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
209 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
210 'transformVia404' => !$wgGenerateThumbnailOnParse,
211 'dbType' => $wgDBtype,
212 'dbServer' => $wgDBserver,
213 'dbUser' => $wgDBuser,
214 'dbPassword' => $wgDBpassword,
215 'dbName' => $wgSharedUploadDBname,
216 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
217 'tablePrefix' => $wgSharedUploadDBprefix,
218 'hasSharedCache' => $wgCacheSharedUploads,
219 'descBaseUrl' => $wgRepositoryBaseUrl,
220 'fetchDescription' => $wgFetchCommonsDescriptions,
221 ];
222 } else {
224 'class' => 'FileRepo',
225 'name' => 'shared',
226 'directory' => $wgSharedUploadDirectory,
227 'url' => $wgSharedUploadPath,
228 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
229 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
230 'transformVia404' => !$wgGenerateThumbnailOnParse,
231 'descBaseUrl' => $wgRepositoryBaseUrl,
232 'fetchDescription' => $wgFetchCommonsDescriptions,
233 ];
234 }
235}
238 'class' => 'ForeignAPIRepo',
239 'name' => 'wikimediacommons',
240 'apibase' => 'https://commons.wikimedia.org/w/api.php',
241 'url' => 'https://upload.wikimedia.org/wikipedia/commons',
242 'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
243 'hashLevels' => 2,
244 'transformVia404' => true,
245 'fetchDescription' => true,
246 'descriptionCacheExpiry' => 43200,
247 'apiThumbCacheExpiry' => 0,
248 ];
249}
250/*
251 * Add on default file backend config for file repos.
252 * FileBackendGroup will handle initializing the backends.
253 */
254if ( !isset( $wgLocalFileRepo['backend'] ) ) {
255 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
256}
257foreach ( $wgForeignFileRepos as &$repo ) {
258 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
259 $repo['directory'] = $wgUploadDirectory; // b/c
260 }
261 if ( !isset( $repo['backend'] ) ) {
262 $repo['backend'] = $repo['name'] . '-backend';
263 }
264}
265unset( $repo ); // no global pollution; destroy reference
266
267$rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
268if ( $wgRCFilterByAge ) {
269 // Trim down $wgRCLinkDays so that it only lists links which are valid
270 // as determined by $wgRCMaxAge.
271 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
272 sort( $wgRCLinkDays );
273
274 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
275 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
276 // @codingStandardsIgnoreEnd
277 if ( $wgRCLinkDays[$i] >= $rcMaxAgeDays ) {
278 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
279 break;
280 }
281 }
282}
283// Ensure that default user options are not invalid, since that breaks Special:Preferences
284$wgDefaultUserOptions['rcdays'] = min(
285 $wgDefaultUserOptions['rcdays'],
286 ceil( $rcMaxAgeDays )
287);
288$wgDefaultUserOptions['watchlistdays'] = min(
289 $wgDefaultUserOptions['watchlistdays'],
290 ceil( $rcMaxAgeDays )
291);
292unset( $rcMaxAgeDays );
293
294if ( $wgSkipSkin ) {
296}
297
298$wgSkipSkins[] = 'fallback';
299$wgSkipSkins[] = 'apioutput';
300
301if ( $wgLocalInterwiki ) {
302 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
303}
304
305// Set default shared prefix
306if ( $wgSharedPrefix === false ) {
308}
309
310// Set default shared schema
311if ( $wgSharedSchema === false ) {
313}
314
315if ( !$wgCookiePrefix ) {
316 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
318 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
320 } elseif ( $wgDBprefix ) {
322 } else {
324 }
325}
326$wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
327
328if ( $wgEnableEmail ) {
330} else {
331 // Disable all other email settings automatically if $wgEnableEmail
332 // is set to false. - T65678
333 $wgAllowHTMLEmail = false;
334 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
344 unset( $wgGroupPermissions['user']['sendemail'] );
348}
349
350if ( $wgMetaNamespace === false ) {
351 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
352}
353
354// Default value is 2000 or the suhosin limit if it is between 1 and 2000
355if ( $wgResourceLoaderMaxQueryLength === false ) {
356 $suhosinMaxValueLength = (int)ini_get( 'suhosin.get.max_value_length' );
357 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
358 $wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength;
359 } else {
361 }
362 unset( $suhosinMaxValueLength );
363}
364
365// Ensure the minimum chunk size is less than PHP upload limits or the maximum
366// upload size.
372 ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ),
373 PHP_INT_MAX
374 ) ?: PHP_INT_MAX ) - 1024 // Leave some room for other POST parameters
375);
376
382 NS_MEDIA => 'Media',
383 NS_SPECIAL => 'Special',
384 NS_TALK => 'Talk',
385 NS_USER => 'User',
386 NS_USER_TALK => 'User_talk',
387 NS_PROJECT => 'Project',
388 NS_PROJECT_TALK => 'Project_talk',
389 NS_FILE => 'File',
390 NS_FILE_TALK => 'File_talk',
391 NS_MEDIAWIKI => 'MediaWiki',
392 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
393 NS_TEMPLATE => 'Template',
394 NS_TEMPLATE_TALK => 'Template_talk',
395 NS_HELP => 'Help',
396 NS_HELP_TALK => 'Help_talk',
397 NS_CATEGORY => 'Category',
398 NS_CATEGORY_TALK => 'Category_talk',
399];
400
402if ( is_array( $wgExtraNamespaces ) ) {
404}
405
406// Merge in the legacy language codes, incorporating overrides from the config
408 'qqq' => 'qqq', // Used for message documentation
409 'qqx' => 'qqx', // Used for viewing message keys
411
412// These are now the same, always
413// To determine the user language, use $wgLang->getCode()
415
416// Easy to forget to falsify $wgDebugToolbar for static caches.
417// If file cache or CDN cache is on, just disable this (DWIMD).
419 $wgDebugToolbar = false;
420}
421
422// We always output HTML5 since 1.22, overriding these is no longer supported
423// we set them here for extensions that depend on its value.
424$wgHtml5 = true;
425$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
426$wgJsMimeType = 'text/javascript';
427
428// Blacklisted file extensions shouldn't appear on the "allowed" list
429$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) );
430
432 MediaWiki\suppressWarnings();
433 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( "$IP/LocalSettings.php" ) ) );
434 MediaWiki\restoreWarnings();
435}
436
437if ( $wgNewUserLog ) {
438 // Add a new log type
439 $wgLogTypes[] = 'newusers';
440 $wgLogNames['newusers'] = 'newuserlogpage';
441 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
442 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
443 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
444 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
445 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
446 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
447}
448
450 $wgLogTypes[] = 'pagelang';
451 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
452}
453
454if ( $wgCookieSecure === 'detect' ) {
456}
457
458if ( $wgProfileOnly ) {
459 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
460 $wgDebugLogFile = '';
461}
462
463// Backwards compatibility with old password limits
464if ( $wgMinimalPasswordLength !== false ) {
465 $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength;
466}
467
468if ( $wgMaximalPasswordLength !== false ) {
469 $wgPasswordPolicy['policies']['default']['MaximalPasswordLength'] = $wgMaximalPasswordLength;
470}
471
472// Backwards compatibility warning
474 wfDeprecated( '$wgSessionsInObjectCache = false', '1.27' );
475 if ( $wgSessionHandler ) {
476 wfDeprecated( '$wgSessionsHandler', '1.27' );
477 }
478 $cacheType = get_class( ObjectCache::getInstance( $wgSessionCacheType ) );
480 'caches',
481 "Session data will be stored in \"$cacheType\" cache with " .
482 "expiry $wgObjectCacheSessionExpiry seconds"
483 );
484}
486
487if ( $wgPHPSessionHandling !== 'enable' &&
488 $wgPHPSessionHandling !== 'warn' &&
489 $wgPHPSessionHandling !== 'disable'
490) {
491 $wgPHPSessionHandling = 'warn';
492}
493if ( defined( 'MW_NO_SESSION' ) ) {
494 // If the entry point wants no session, force 'disable' here unless they
495 // specifically set it to the (undocumented) 'warn'.
496 $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
497}
498
499Profiler::instance()->scopedProfileOut( $ps_default );
500
501// Disable MWDebug for command line mode, this prevents MWDebug from eating up
502// all the memory from logging SQL queries on maintenance scripts
505 MWDebug::init();
506}
507
508// Reset the global service locator, so any services that have already been created will be
509// re-created while taking into account any custom settings and extensions.
510MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' );
511
513 // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
514 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
515 array_fill_keys(
517 [
518 'dbname' => $wgSharedDB,
519 'schema' => $wgSharedSchema,
520 'prefix' => $wgSharedPrefix
521 ]
522 )
523 );
524}
525
526// Define a constant that indicates that the bootstrapping of the service locator
527// is complete.
528define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
529
530MWExceptionHandler::installHandler();
531
532require_once "$IP/includes/compat/normal/UtfNormalUtil.php";
533
534$ps_validation = Profiler::instance()->scopedProfileIn( $fname . '-validation' );
535
536// T48998: Bail out early if $wgArticlePath is non-absolute
537foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) {
538 if ( $$varName && !preg_match( '/^(https?:\/\/|\/)/', $$varName ) ) {
539 throw new FatalError(
540 "If you use a relative URL for \$$varName, it must start " .
541 'with a slash (<code>/</code>).<br><br>See ' .
542 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
543 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
544 );
545 }
546}
547
548Profiler::instance()->scopedProfileOut( $ps_validation );
549
550$ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' );
551
552if ( $wgCanonicalServer === false ) {
554}
555
556// Set server name
558if ( $wgServerName !== false ) {
559 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
560 . 'not customized. Overwriting $wgServerName.' );
561}
563unset( $serverParts );
564
565// Set defaults for configuration variables
566// that are derived from the server name by default
567// Note: $wgEmergencyContact and $wgPasswordSender may be false or empty string (T104142)
568if ( !$wgEmergencyContact ) {
569 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
570}
571if ( !$wgPasswordSender ) {
572 $wgPasswordSender = 'apache@' . $wgServerName;
573}
574if ( !$wgNoReplyAddress ) {
576}
577
578if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
579 $wgSecureLogin = false;
580 wfWarn( 'Secure login was enabled on a server that only supports '
581 . 'HTTP or HTTPS. Disabling secure login.' );
582}
583
585
586// Now that GlobalFunctions is loaded, set defaults that depend on it.
587if ( $wgTmpDirectory === false ) {
589}
590
591// We don't use counters anymore. Left here for extensions still
592// expecting this to exist. Should be removed sometime 1.26 or later.
593if ( !isset( $wgDisableCounters ) ) {
594 $wgDisableCounters = true;
595}
596
597if ( $wgMainWANCache === false ) {
598 // Setup a WAN cache from $wgMainCacheType with no relayer.
599 // Sites using multiple datacenters can configure a relayer.
600 $wgMainWANCache = 'mediawiki-main-default';
602 'class' => 'WANObjectCache',
603 'cacheId' => $wgMainCacheType,
604 'channels' => [ 'purge' => 'wancache-main-default-purge' ]
605 ];
606}
607
608Profiler::instance()->scopedProfileOut( $ps_default2 );
609
610$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc1' );
611
612// Raise the memory limit if it's too low
614
620if ( is_null( $wgLocaltimezone ) ) {
621 MediaWiki\suppressWarnings();
622 $wgLocaltimezone = date_default_timezone_get();
623 MediaWiki\restoreWarnings();
624}
625
626date_default_timezone_set( $wgLocaltimezone );
627if ( is_null( $wgLocalTZoffset ) ) {
628 $wgLocalTZoffset = date( 'Z' ) / 60;
629}
630// The part after the System| is ignored, but rest of MW fills it
631// out as the local offset.
632$wgDefaultUserOptions['timecorrection'] = "System|$wgLocalTZoffset";
633
634if ( !$wgDBerrorLogTZ ) {
636}
637
638// initialize the request object in $wgRequest
639$wgRequest = RequestContext::getMain()->getRequest(); // BackCompat
640// Set user IP/agent information for causal consistency purposes
641MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
642 'IPAddress' => $wgRequest->getIP(),
643 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ),
644 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' )
645] );
646
647// Useful debug output
648if ( $wgCommandLineMode ) {
649 wfDebug( "\n\nStart command line script $self\n" );
650} else {
651 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
652
654 $debug .= "HTTP HEADERS:\n";
655
656 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
657 $debug .= "$name: $value\n";
658 }
659 }
660 wfDebug( $debug );
661}
662
663Profiler::instance()->scopedProfileOut( $ps_misc );
664$ps_memcached = Profiler::instance()->scopedProfileIn( $fname . '-memcached' );
665
669
670wfDebugLog( 'caches',
671 'cluster: ' . get_class( $wgMemc ) .
672 ', WAN: ' . ( $wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache ) .
673 ', stash: ' . $wgMainStash .
674 ', message: ' . get_class( $messageMemc ) .
675 ', parser: ' . get_class( $parserMemc ) .
676 ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) )
677);
678
679Profiler::instance()->scopedProfileOut( $ps_memcached );
680
681// Most of the config is out, some might want to run hooks here.
682Hooks::run( 'SetupAfterCache' );
683
684$ps_globals = Profiler::instance()->scopedProfileIn( $fname . '-globals' );
685
689$wgContLang = Language::factory( $wgLanguageCode );
690$wgContLang->initContLang();
691
692// Now that variant lists may be available...
693$wgRequest->interpolateTitle();
694
695if ( !is_object( $wgAuth ) ) {
697 Hooks::run( 'AuthPluginSetup', [ &$wgAuth ] );
698}
699if ( $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin ) {
700 MediaWiki\Auth\AuthManager::singleton()->forcePrimaryAuthenticationProviders( [
701 new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [
702 'authoritative' => false,
703 ] ),
704 new MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider( $wgAuth ),
705 new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [
706 'authoritative' => true,
707 ] ),
708 ], '$wgAuth is ' . get_class( $wgAuth ) );
709}
710
711// Set up the session
712$ps_session = Profiler::instance()->scopedProfileIn( $fname . '-session' );
718if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
719 // If session.auto_start is there, we can't touch session name
720 if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ) {
721 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
722 }
723
724 // Create the SessionManager singleton and set up our session handler,
725 // unless we're specifically asked not to.
726 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
727 MediaWiki\Session\PHPSessionHandler::install(
728 MediaWiki\Session\SessionManager::singleton()
729 );
730 }
731
732 // Initialize the session
733 try {
734 $session = MediaWiki\Session\SessionManager::getGlobalSession();
735 } catch ( OverflowException $ex ) {
736 if ( isset( $ex->sessionInfos ) && count( $ex->sessionInfos ) >= 2 ) {
737 // The exception is because the request had multiple possible
738 // sessions tied for top priority. Report this to the user.
739 $list = [];
740 foreach ( $ex->sessionInfos as $info ) {
741 $list[] = $info->getProvider()->describe( $wgContLang );
742 }
743 $list = $wgContLang->listToText( $list );
744 throw new HttpError( 400,
745 Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $wgContLang )->plain()
746 );
747 }
748
749 // Not the one we want, rethrow
750 throw $ex;
751 }
752
753 if ( $session->isPersistent() ) {
754 $wgInitialSessionId = $session->getSessionId();
755 }
756
757 $session->renew();
758 if ( MediaWiki\Session\PHPSessionHandler::isEnabled() &&
759 ( $session->isPersistent() || $session->shouldRememberUser() )
760 ) {
761 // Start the PHP-session for backwards compatibility
762 session_id( $session->getId() );
763 MediaWiki\quietCall( 'session_start' );
764 }
765
766 unset( $session );
767} else {
768 // Even if we didn't set up a global Session, still install our session
769 // handler unless specifically requested not to.
770 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
771 MediaWiki\Session\PHPSessionHandler::install(
772 MediaWiki\Session\SessionManager::singleton()
773 );
774 }
775}
776Profiler::instance()->scopedProfileOut( $ps_session );
777
781$wgUser = RequestContext::getMain()->getUser(); // BackCompat
782
787
791$wgOut = RequestContext::getMain()->getOutput(); // BackCompat
792
796$wgParser = new StubObject( 'wgParser', function () {
797 return MediaWikiServices::getInstance()->getParser();
798} );
799
803$wgTitle = null;
804
805Profiler::instance()->scopedProfileOut( $ps_globals );
806$ps_extensions = Profiler::instance()->scopedProfileIn( $fname . '-extensions' );
807
808// Extension setup functions
809// Entries should be added to this variable during the inclusion
810// of the extension file. This allows the extension to perform
811// any necessary initialisation in the fully initialised environment
812foreach ( $wgExtensionFunctions as $func ) {
813 // Allow closures in PHP 5.3+
814 if ( is_object( $func ) && $func instanceof Closure ) {
815 $profName = $fname . '-extensions-closure';
816 } elseif ( is_array( $func ) ) {
817 if ( is_object( $func[0] ) ) {
818 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
819 } else {
820 $profName = $fname . '-extensions-' . implode( '::', $func );
821 }
822 } else {
823 $profName = $fname . '-extensions-' . strval( $func );
824 }
825
826 $ps_ext_func = Profiler::instance()->scopedProfileIn( $profName );
827 call_user_func( $func );
828 Profiler::instance()->scopedProfileOut( $ps_ext_func );
829}
830
831// If the session user has a 0 id but a valid name, that means we need to
832// autocreate it.
833if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
834 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
835 if ( $sessionUser->getId() === 0 && User::isValidUserName( $sessionUser->getName() ) ) {
836 $ps_autocreate = Profiler::instance()->scopedProfileIn( $fname . '-autocreate' );
837 $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser(
838 $sessionUser,
839 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
840 true
841 );
842 Profiler::instance()->scopedProfileOut( $ps_autocreate );
843 \MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [
844 'event' => 'autocreate',
845 'status' => $res,
846 ] );
847 unset( $res );
848 }
849 unset( $sessionUser );
850}
851
852if ( !$wgCommandLineMode ) {
854}
855
857
858Profiler::instance()->scopedProfileOut( $ps_extensions );
859Profiler::instance()->scopedProfileOut( $ps_setup );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$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.
$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.
$wgParserCacheType
The cache type for storing article HTML.
$wgSessionHandler
$wgSharedThumbnailScriptPath
$wgEmergencyContact
Site admin email address.
$wgDBprefix
Table name prefix.
$wgDBuser
Database username.
string $wgPHPSessionHandling
Whether to use PHP session handling ($_SESSION and session_*() functions)
$wgScript
The URL path to index.php.
$wgUseInstantCommons
Use Commons as a remote file repository.
$wgCacheDirectory
Directory for caching data in the local filesystem.
$wgHashedSharedUploadDirectory
Set the following to false especially if you have a set of files that need to be accessible by all wi...
$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 local wiki users.
$wgLogNames
Lists the message key string for each log type.
$wgSharedUploadPath
Full path on the web server where shared uploads can be found.
$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.
$wgDBtype
Database type.
$wgDBmwschema
Mediawiki schema.
$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.
$wgSharedUploadDirectory
Path on the file system where shared uploads can be found.
$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.
$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.
$wgCacheSharedUploads
Cache shared metadata in memcached.
$wgEnableParserCache
Kept for extension compatibility; see $wgParserCacheType.
$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.
$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.
$wgGroupPermissions
Permission keys given to users in each group.
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
$wgVersion
MediaWiki version number.
$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.
$wgAuth $wgAuth
Authentication plugin.
$wgAllowHTMLEmail
For parts of the system that have been updated to provide HTML email content, send both text and HTML...
$wgSharedUploadDBname
DB name with metadata about shared directory.
$wgMainStash
Main object stash type.
$wgExtensionAssetsPath
The URL path of the extensions directory.
$wgDebugToolbar
Display the new debugging toolbar.
$wgForeignFileRepos
$wgRepositoryBaseUrl
Base URL for a repository wiki.
$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.
$wgSharedUploadDBprefix
Optional table prefix used in database.
$wgDebugDumpSql
Write SQL queries to the debug log.
$wgFetchCommonsDescriptions
Fetch commons image description pages and display them on the local wiki?
$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.
$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.
$wgUseSharedUploads
If you operate multiple wikis, you can define a shared upload path here.
$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 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.
wfGetMainCache()
Get the main cache object.
wfGetParserCacheStorage()
Get the cache object used by the parser cache.
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.
$ps_extensions
Definition Setup.php:806
$messageMemc
Definition Setup.php:667
$parserMemc
Definition Setup.php:668
$wgFileExtensions
Definition Setup.php:429
$wgEnotifWatchlist
Definition Setup.php:343
$ps_memcached
Definition Setup.php:664
$wgEnotifMaxRecips
Definition Setup.php:338
$wgEnotifUserTalk
Definition Setup.php:342
if($wgInvalidateCacheOnLocalSettingsChange) if( $wgNewUserLog) if($wgPageLanguageUseDB) if( $wgCookieSecure==='detect') if($wgProfileOnly) if( $wgMinimalPasswordLength !==false) if($wgMaximalPasswordLength !==false) if(! $wgSessionsInObjectCache) $wgSessionsInObjectCache
Definition Setup.php:485
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
Definition Setup.php:284
$wgUser
Definition Setup.php:781
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Definition Setup.php:36
$wgEnableUserEmail
Definition Setup.php:335
$rcMaxAgeDays
Definition Setup.php:267
if( $wgUseFileCache|| $wgUseSquid) $wgHtml5
Definition Setup.php:424
$ps_validation
Definition Setup.php:534
$wgOut
Definition Setup.php:791
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
Definition Setup.php:381
$wgMemc
Definition Setup.php:666
$wgParser
Definition Setup.php:796
global $wgCommandLineMode
Definition Setup.php:503
foreach( $wgExtensionFunctions as $func) if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
Definition Setup.php:856
$wgTitle
Definition Setup.php:803
if(is_array( $wgExtraNamespaces)) $wgDummyLanguageCodes
Definition Setup.php:407
if(!is_object($wgAuth)) if( $wgAuth &&! $wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin) $ps_session
Definition Setup.php:712
$wgEnotifFromEditor
Definition Setup.php:336
$wgJsMimeType
Definition Setup.php:426
$wgUseEnotif
Definition Setup.php:345
$wgEnotifRevealEditorAddress
Definition Setup.php:340
$wgInitialSessionId
Definition Setup.php:717
$wgEnotifImpersonal
Definition Setup.php:337
$wgContLanguageCode
Definition Setup.php:414
$wgUsersNotifiedOnAllChanges
Definition Setup.php:347
$wgUserEmailUseReplyTo
Definition Setup.php:346
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:639
$wgLang
Definition Setup.php:786
$ps_default2
Definition Setup.php:550
$wgContLang
Definition Setup.php:689
$ps_default
Definition Setup.php:53
if($wgLocalInterwiki) if( $wgSharedPrefix===false) if($wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
Definition Setup.php:326
if( $wgServerName !==false) $wgServerName
Definition Setup.php:562
$wgEnotifMinorEdits
Definition Setup.php:339
$ps_setup
Definition Setup.php:37
$ps_globals
Definition Setup.php:684
$wgXhtmlDefaultNamespace
Definition Setup.php:425
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
Definition Setup.php:170
$wgEmailAuthentication
Definition Setup.php:334
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
Definition Setup.php:164
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
Definition Setup.php:584
if( $wgCanonicalServer===false) $serverParts
Definition Setup.php:557
$ps_misc
Definition Setup.php:610
if( $wgSkipSkin) $wgSkipSkins[]
Definition Setup.php:298
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($wgEnableParserCache===false) if( $wgRightsIcon) if(isset($wgFooterIcons[ 'copyright'][ 'copyright']) &&$wgFooterIcons[ 'copyright'][ 'copyright']===[]) if(isset( $wgFooterIcons['poweredby']) &&isset( $wgFooterIcons['poweredby']['mediawiki']) && $wgFooterIcons['poweredby']['mediawiki']['src']===null) $wgNamespaceProtection[NS_MEDIAWIKI]
Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a sysadmin to set $wgName...
Definition Setup.php:157
$wgEnotifUseRealName
Definition Setup.php:341
if($wgMetaNamespace===false) if( $wgResourceLoaderMaxQueryLength===false) $wgMinUploadChunkSize
Definition Setup.php:367
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
static getDeprecatedCodeMapping()
Returns a mapping of deprecated language codes that were used in previous versions of MediaWiki to up...
Backwards-compatibility wrapper for AuthManager via $wgAuth.
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:253
static instance()
Singleton.
Definition Profiler.php:62
static getMain()
Static methods.
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 detectProtocol()
Detect the protocol from $_SERVER.
$res
Definition database.txt:21
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const NS_HELP
Definition Defines.php:74
const NS_USER
Definition Defines.php:64
const NS_FILE
Definition Defines.php:68
const CACHE_NONE
Definition Defines.php:100
const NS_MEDIAWIKI_TALK
Definition Defines.php:71
const NS_PROJECT_TALK
Definition Defines.php:67
const NS_MEDIAWIKI
Definition Defines.php:70
const NS_TEMPLATE
Definition Defines.php:72
const NS_SPECIAL
Definition Defines.php:51
const NS_FILE_TALK
Definition Defines.php:69
const NS_HELP_TALK
Definition Defines.php:75
const NS_CATEGORY_TALK
Definition Defines.php:77
const PROTO_HTTP
Definition Defines.php:217
const NS_MEDIA
Definition Defines.php:50
const NS_TALK
Definition Defines.php:63
const NS_USER_TALK
Definition Defines.php:65
const NS_PROJECT
Definition Defines.php:66
const NS_CATEGORY
Definition Defines.php:76
const NS_TEMPLATE_TALK
Definition Defines.php:73
either a plain
Definition hooks.txt:2007
$wgActionPaths
Definition img_auth.php:46
$wgArticlePath
Definition img_auth.php:45
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
const MW_NO_SESSION
Definition load.php:30
$debug
Definition mcc.php:31
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $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