MediaWiki REL1_28
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// If any extensions are still queued, force load them
40ExtensionRegistry::getInstance()->loadFromQueue();
41
42// Check to see if we are at the file scope
43if ( !isset( $wgVersion ) ) {
44 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
45 die( 1 );
46}
47
48mb_internal_encoding( 'UTF-8' );
49
50// Set various default paths sensibly...
51$ps_default = Profiler::instance()->scopedProfileIn( $fname . '-defaults' );
52
53if ( $wgScript === false ) {
54 $wgScript = "$wgScriptPath/index.php";
55}
56if ( $wgLoadScript === false ) {
57 $wgLoadScript = "$wgScriptPath/load.php";
58}
59
60if ( $wgArticlePath === false ) {
61 if ( $wgUsePathInfo ) {
62 $wgArticlePath = "$wgScript/$1";
63 } else {
64 $wgArticlePath = "$wgScript?title=$1";
65 }
66}
67
68if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
69 // 'view' is assumed the default action path everywhere in the code
70 // but is rarely filled in $wgActionPaths
72}
73
74if ( $wgResourceBasePath === null ) {
76}
77if ( $wgStylePath === false ) {
78 $wgStylePath = "$wgResourceBasePath/skins";
79}
80if ( $wgLocalStylePath === false ) {
81 // Avoid wgResourceBasePath here since that may point to a different domain (e.g. CDN)
82 $wgLocalStylePath = "$wgScriptPath/skins";
83}
84if ( $wgExtensionAssetsPath === false ) {
85 $wgExtensionAssetsPath = "$wgResourceBasePath/extensions";
86}
87
88if ( $wgLogo === false ) {
89 $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";
90}
91
92if ( $wgUploadPath === false ) {
93 $wgUploadPath = "$wgScriptPath/images";
94}
95if ( $wgUploadDirectory === false ) {
96 $wgUploadDirectory = "$IP/images";
97}
98if ( $wgReadOnlyFile === false ) {
99 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
100}
101if ( $wgFileCacheDirectory === false ) {
102 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
103}
104if ( $wgDeletedDirectory === false ) {
105 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
106}
107
108if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
109 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
110}
111
112if ( $wgEnableParserCache === false ) {
114}
115
116// Fix path to icon images after they were moved in 1.24
117if ( $wgRightsIcon ) {
118 $wgRightsIcon = str_replace(
119 "{$wgStylePath}/common/images/",
120 "{$wgResourceBasePath}/resources/assets/licenses/",
122 );
123}
124
125if ( isset( $wgFooterIcons['copyright']['copyright'] )
126 && $wgFooterIcons['copyright']['copyright'] === []
127) {
128 if ( $wgRightsIcon || $wgRightsText ) {
129 $wgFooterIcons['copyright']['copyright'] = [
130 'url' => $wgRightsUrl,
131 'src' => $wgRightsIcon,
132 'alt' => $wgRightsText,
133 ];
134 }
135}
136
137if ( isset( $wgFooterIcons['poweredby'] )
138 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
139 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
140) {
141 $wgFooterIcons['poweredby']['mediawiki']['src'] =
142 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_88x31.png";
143 $wgFooterIcons['poweredby']['mediawiki']['srcset'] =
144 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_132x47.png 1.5x, " .
145 "$wgResourceBasePath/resources/assets/poweredby_mediawiki_176x62.png 2x";
146}
147
156
164
169 'name' => 'fsLockManager',
170 'class' => 'FSLockManager',
171 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
172];
173$wgLockManagers[] = [
174 'name' => 'nullLockManager',
175 'class' => 'NullLockManager',
176];
177
181if ( !$wgLocalFileRepo ) {
183 'class' => 'LocalRepo',
184 'name' => 'local',
185 'directory' => $wgUploadDirectory,
186 'scriptDirUrl' => $wgScriptPath,
187 'scriptExtension' => '.php',
189 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
190 'thumbScriptUrl' => $wgThumbnailScriptPath,
191 'transformVia404' => !$wgGenerateThumbnailOnParse,
192 'deletedDir' => $wgDeletedDirectory,
193 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0
194 ];
195}
199if ( $wgUseSharedUploads ) {
200 if ( $wgSharedUploadDBname ) {
202 'class' => 'ForeignDBRepo',
203 'name' => 'shared',
204 'directory' => $wgSharedUploadDirectory,
205 'url' => $wgSharedUploadPath,
206 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
207 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
208 'transformVia404' => !$wgGenerateThumbnailOnParse,
209 'dbType' => $wgDBtype,
210 'dbServer' => $wgDBserver,
211 'dbUser' => $wgDBuser,
212 'dbPassword' => $wgDBpassword,
213 'dbName' => $wgSharedUploadDBname,
214 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
215 'tablePrefix' => $wgSharedUploadDBprefix,
216 'hasSharedCache' => $wgCacheSharedUploads,
217 'descBaseUrl' => $wgRepositoryBaseUrl,
218 'fetchDescription' => $wgFetchCommonsDescriptions,
219 ];
220 } else {
222 'class' => 'FileRepo',
223 'name' => 'shared',
224 'directory' => $wgSharedUploadDirectory,
225 'url' => $wgSharedUploadPath,
226 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
227 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
228 'transformVia404' => !$wgGenerateThumbnailOnParse,
229 'descBaseUrl' => $wgRepositoryBaseUrl,
230 'fetchDescription' => $wgFetchCommonsDescriptions,
231 ];
232 }
233}
236 'class' => 'ForeignAPIRepo',
237 'name' => 'wikimediacommons',
238 'apibase' => 'https://commons.wikimedia.org/w/api.php',
239 'url' => 'https://upload.wikimedia.org/wikipedia/commons',
240 'thumbUrl' => 'https://upload.wikimedia.org/wikipedia/commons/thumb',
241 'hashLevels' => 2,
242 'transformVia404' => true,
243 'fetchDescription' => true,
244 'descriptionCacheExpiry' => 43200,
245 'apiThumbCacheExpiry' => 0,
246 ];
247}
248/*
249 * Add on default file backend config for file repos.
250 * FileBackendGroup will handle initializing the backends.
251 */
252if ( !isset( $wgLocalFileRepo['backend'] ) ) {
253 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
254}
255foreach ( $wgForeignFileRepos as &$repo ) {
256 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
257 $repo['directory'] = $wgUploadDirectory; // b/c
258 }
259 if ( !isset( $repo['backend'] ) ) {
260 $repo['backend'] = $repo['name'] . '-backend';
261 }
262}
263unset( $repo ); // no global pollution; destroy reference
264
265$rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 );
266if ( $wgRCFilterByAge ) {
267 // Trim down $wgRCLinkDays so that it only lists links which are valid
268 // as determined by $wgRCMaxAge.
269 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
270 sort( $wgRCLinkDays );
271
272 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
273 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
274 // @codingStandardsIgnoreEnd
275 if ( $wgRCLinkDays[$i] >= $rcMaxAgeDays ) {
276 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
277 break;
278 }
279 }
280}
281// Ensure that default user options are not invalid, since that breaks Special:Preferences
282$wgDefaultUserOptions['rcdays'] = min(
283 $wgDefaultUserOptions['rcdays'],
284 ceil( $rcMaxAgeDays )
285);
286$wgDefaultUserOptions['watchlistdays'] = min(
287 $wgDefaultUserOptions['watchlistdays'],
288 ceil( $rcMaxAgeDays )
289);
290unset( $rcMaxAgeDays );
291
292if ( $wgSkipSkin ) {
294}
295
296$wgSkipSkins[] = 'fallback';
297$wgSkipSkins[] = 'apioutput';
298
299if ( $wgLocalInterwiki ) {
300 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
301}
302
303// Set default shared prefix
304if ( $wgSharedPrefix === false ) {
306}
307
308// Set default shared schema
309if ( $wgSharedSchema === false ) {
311}
312
313if ( !$wgCookiePrefix ) {
314 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
316 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
318 } elseif ( $wgDBprefix ) {
320 } else {
322 }
323}
324$wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
325
326if ( $wgEnableEmail ) {
328} else {
329 // Disable all other email settings automatically if $wgEnableEmail
330 // is set to false. - bug 63678
331 $wgAllowHTMLEmail = false;
332 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
342 unset( $wgGroupPermissions['user']['sendemail'] );
346}
347
348if ( $wgMetaNamespace === false ) {
349 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
350}
351
352// Default value is 2000 or the suhosin limit if it is between 1 and 2000
353if ( $wgResourceLoaderMaxQueryLength === false ) {
354 $suhosinMaxValueLength = (int)ini_get( 'suhosin.get.max_value_length' );
355 if ( $suhosinMaxValueLength > 0 && $suhosinMaxValueLength < 2000 ) {
356 $wgResourceLoaderMaxQueryLength = $suhosinMaxValueLength;
357 } else {
359 }
360 unset( $suhosinMaxValueLength );
361}
362
363// Ensure the minimum chunk size is less than PHP upload limits or the maximum
364// upload size.
370 ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ),
371 PHP_INT_MAX
372 ) ?: PHP_INT_MAX ) - 1024 // Leave some room for other POST parameters
373);
374
380 NS_MEDIA => 'Media',
381 NS_SPECIAL => 'Special',
382 NS_TALK => 'Talk',
383 NS_USER => 'User',
384 NS_USER_TALK => 'User_talk',
385 NS_PROJECT => 'Project',
386 NS_PROJECT_TALK => 'Project_talk',
387 NS_FILE => 'File',
388 NS_FILE_TALK => 'File_talk',
389 NS_MEDIAWIKI => 'MediaWiki',
390 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
391 NS_TEMPLATE => 'Template',
392 NS_TEMPLATE_TALK => 'Template_talk',
393 NS_HELP => 'Help',
394 NS_HELP_TALK => 'Help_talk',
395 NS_CATEGORY => 'Category',
396 NS_CATEGORY_TALK => 'Category_talk',
397];
398
400if ( is_array( $wgExtraNamespaces ) ) {
402}
403
404// These are now the same, always
405// To determine the user language, use $wgLang->getCode()
407
408// Easy to forget to falsify $wgDebugToolbar for static caches.
409// If file cache or CDN cache is on, just disable this (DWIMD).
411 $wgDebugToolbar = false;
412}
413
414// We always output HTML5 since 1.22, overriding these is no longer supported
415// we set them here for extensions that depend on its value.
416$wgHtml5 = true;
417$wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
418$wgJsMimeType = 'text/javascript';
419
420// Blacklisted file extensions shouldn't appear on the "allowed" list
421$wgFileExtensions = array_values( array_diff( $wgFileExtensions, $wgFileBlacklist ) );
422
424 MediaWiki\suppressWarnings();
425 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', filemtime( "$IP/LocalSettings.php" ) ) );
426 MediaWiki\restoreWarnings();
427}
428
429if ( $wgNewUserLog ) {
430 // Add a new log type
431 $wgLogTypes[] = 'newusers';
432 $wgLogNames['newusers'] = 'newuserlogpage';
433 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
434 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
435 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
436 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
437 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
438 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
439}
440
442 $wgLogTypes[] = 'pagelang';
443 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
444}
445
446if ( $wgCookieSecure === 'detect' ) {
448}
449
450if ( $wgProfileOnly ) {
451 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
452 $wgDebugLogFile = '';
453}
454
455// Backwards compatibility with old password limits
456if ( $wgMinimalPasswordLength !== false ) {
457 $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength;
458}
459
460if ( $wgMaximalPasswordLength !== false ) {
461 $wgPasswordPolicy['policies']['default']['MaximalPasswordLength'] = $wgMaximalPasswordLength;
462}
463
464// Backwards compatibility warning
466 wfDeprecated( '$wgSessionsInObjectCache = false', '1.27' );
467 if ( $wgSessionHandler ) {
468 wfDeprecated( '$wgSessionsHandler', '1.27' );
469 }
470 $cacheType = get_class( ObjectCache::getInstance( $wgSessionCacheType ) );
472 'caches',
473 "Session data will be stored in \"$cacheType\" cache with " .
474 "expiry $wgObjectCacheSessionExpiry seconds"
475 );
476}
478
479if ( $wgPHPSessionHandling !== 'enable' &&
480 $wgPHPSessionHandling !== 'warn' &&
481 $wgPHPSessionHandling !== 'disable'
482) {
483 $wgPHPSessionHandling = 'warn';
484}
485if ( defined( 'MW_NO_SESSION' ) ) {
486 // If the entry point wants no session, force 'disable' here unless they
487 // specifically set it to the (undocumented) 'warn'.
488 $wgPHPSessionHandling = MW_NO_SESSION === 'warn' ? 'warn' : 'disable';
489}
490
491Profiler::instance()->scopedProfileOut( $ps_default );
492
493// Disable MWDebug for command line mode, this prevents MWDebug from eating up
494// all the memory from logging SQL queries on maintenance scripts
497 MWDebug::init();
498}
499
500if ( !class_exists( 'AutoLoader' ) ) {
501 require_once "$IP/includes/AutoLoader.php";
502}
503
504// Reset the global service locator, so any services that have already been created will be
505// re-created while taking into account any custom settings and extensions.
506MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' );
507
509 // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
510 MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
511 array_fill_keys(
513 [
514 'dbname' => $wgSharedDB,
515 'schema' => $wgSharedSchema,
516 'prefix' => $wgSharedPrefix
517 ]
518 )
519 );
520}
521
522// Define a constant that indicates that the bootstrapping of the service locator
523// is complete.
524define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
525
526// Install a header callback to prevent caching of responses with cookies (T127993)
527if ( !$wgCommandLineMode ) {
528 header_register_callback( function () {
529 $headers = [];
530 foreach ( headers_list() as $header ) {
531 list( $name, $value ) = explode( ':', $header, 2 );
532 $headers[strtolower( trim( $name ) )][] = trim( $value );
533 }
534
535 if ( isset( $headers['set-cookie'] ) ) {
536 $cacheControl = isset( $headers['cache-control'] )
537 ? implode( ', ', $headers['cache-control'] )
538 : '';
539
540 if ( !preg_match( '/(?:^|,)\s*(?:private|no-cache|no-store)\s*(?:$|,)/i', $cacheControl ) ) {
541 header( 'Expires: Thu, 01 Jan 1970 00:00:00 GMT' );
542 header( 'Cache-Control: private, max-age=0, s-maxage=0' );
543 MediaWiki\Logger\LoggerFactory::getInstance( 'cache-cookies' )->warning(
544 'Cookies set on {url} with Cache-Control "{cache-control}"', [
545 'url' => WebRequest::getGlobalRequestURL(),
546 'cookies' => $headers['set-cookie'],
547 'cache-control' => $cacheControl ?: '<not set>',
548 ]
549 );
550 }
551 }
552 } );
553}
554
556
557require_once "$IP/includes/compat/normal/UtfNormalUtil.php";
558
559$ps_validation = Profiler::instance()->scopedProfileIn( $fname . '-validation' );
560
561// T48998: Bail out early if $wgArticlePath is non-absolute
562foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) {
563 if ( $$varName && !preg_match( '/^(https?:\/\/|\/)/', $$varName ) ) {
564 throw new FatalError(
565 "If you use a relative URL for \$$varName, it must start " .
566 'with a slash (<code>/</code>).<br><br>See ' .
567 "<a href=\"https://www.mediawiki.org/wiki/Manual:\$$varName\">" .
568 "https://www.mediawiki.org/wiki/Manual:\$$varName</a>."
569 );
570 }
571}
572
573Profiler::instance()->scopedProfileOut( $ps_validation );
574
575$ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' );
576
577if ( $wgCanonicalServer === false ) {
579}
580
581// Set server name
583if ( $wgServerName !== false ) {
584 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
585 . 'not customized. Overwriting $wgServerName.' );
586}
588unset( $serverParts );
589
590// Set defaults for configuration variables
591// that are derived from the server name by default
592// Note: $wgEmergencyContact and $wgPasswordSender may be false or empty string (T104142)
593if ( !$wgEmergencyContact ) {
594 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
595}
596if ( !$wgPasswordSender ) {
597 $wgPasswordSender = 'apache@' . $wgServerName;
598}
599if ( !$wgNoReplyAddress ) {
601}
602
603if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
604 $wgSecureLogin = false;
605 wfWarn( 'Secure login was enabled on a server that only supports '
606 . 'HTTP or HTTPS. Disabling secure login.' );
607}
608
610
611// Now that GlobalFunctions is loaded, set defaults that depend on it.
612if ( $wgTmpDirectory === false ) {
614}
615
616// We don't use counters anymore. Left here for extensions still
617// expecting this to exist. Should be removed sometime 1.26 or later.
618if ( !isset( $wgDisableCounters ) ) {
619 $wgDisableCounters = true;
620}
621
622if ( $wgMainWANCache === false ) {
623 // Setup a WAN cache from $wgMainCacheType with no relayer.
624 // Sites using multiple datacenters can configure a relayer.
625 $wgMainWANCache = 'mediawiki-main-default';
627 'class' => 'WANObjectCache',
628 'cacheId' => $wgMainCacheType,
629 'channels' => [ 'purge' => 'wancache-main-default-purge' ]
630 ];
631}
632
633Profiler::instance()->scopedProfileOut( $ps_default2 );
634
635$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc1' );
636
637// Raise the memory limit if it's too low
639
645if ( is_null( $wgLocaltimezone ) ) {
646 MediaWiki\suppressWarnings();
647 $wgLocaltimezone = date_default_timezone_get();
648 MediaWiki\restoreWarnings();
649}
650
651date_default_timezone_set( $wgLocaltimezone );
652if ( is_null( $wgLocalTZoffset ) ) {
653 $wgLocalTZoffset = date( 'Z' ) / 60;
654}
655// The part after the System| is ignored, but rest of MW fills it
656// out as the local offset.
657$wgDefaultUserOptions['timecorrection'] = "System|$wgLocalTZoffset";
658
659if ( !$wgDBerrorLogTZ ) {
661}
662
663// initialize the request object in $wgRequest
664$wgRequest = RequestContext::getMain()->getRequest(); // BackCompat
665// Set user IP/agent information for causal consistency purposes
666MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [
667 'IPAddress' => $wgRequest->getIP(),
668 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ),
669 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' )
670] );
671
672// Useful debug output
673if ( $wgCommandLineMode ) {
674 wfDebug( "\n\nStart command line script $self\n" );
675} else {
676 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
677
679 $debug .= "HTTP HEADERS:\n";
680
681 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
682 $debug .= "$name: $value\n";
683 }
684 }
685 wfDebug( $debug );
686}
687
688Profiler::instance()->scopedProfileOut( $ps_misc );
689$ps_memcached = Profiler::instance()->scopedProfileIn( $fname . '-memcached' );
690
694
695wfDebugLog( 'caches',
696 'cluster: ' . get_class( $wgMemc ) .
697 ', WAN: ' . ( $wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache ) .
698 ', stash: ' . $wgMainStash .
699 ', message: ' . get_class( $messageMemc ) .
700 ', parser: ' . get_class( $parserMemc ) .
701 ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) )
702);
703
704Profiler::instance()->scopedProfileOut( $ps_memcached );
705
706// Most of the config is out, some might want to run hooks here.
707Hooks::run( 'SetupAfterCache' );
708
709$ps_globals = Profiler::instance()->scopedProfileIn( $fname . '-globals' );
710
714$wgContLang = Language::factory( $wgLanguageCode );
715$wgContLang->initContLang();
716
717// Now that variant lists may be available...
718$wgRequest->interpolateTitle();
719
720if ( !is_object( $wgAuth ) ) {
722 Hooks::run( 'AuthPluginSetup', [ &$wgAuth ] );
723}
724if ( $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin ) {
725 MediaWiki\Auth\AuthManager::singleton()->forcePrimaryAuthenticationProviders( [
726 new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [
727 'authoritative' => false,
728 ] ),
729 new MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider( $wgAuth ),
730 new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [
731 'authoritative' => true,
732 ] ),
733 ], '$wgAuth is ' . get_class( $wgAuth ) );
734}
735
736// Set up the session
737$ps_session = Profiler::instance()->scopedProfileIn( $fname . '-session' );
743if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
744 // If session.auto_start is there, we can't touch session name
745 if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ) {
746 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
747 }
748
749 // Create the SessionManager singleton and set up our session handler,
750 // unless we're specifically asked not to.
751 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
752 MediaWiki\Session\PHPSessionHandler::install(
753 MediaWiki\Session\SessionManager::singleton()
754 );
755 }
756
757 // Initialize the session
758 try {
759 $session = MediaWiki\Session\SessionManager::getGlobalSession();
760 } catch ( OverflowException $ex ) {
761 if ( isset( $ex->sessionInfos ) && count( $ex->sessionInfos ) >= 2 ) {
762 // The exception is because the request had multiple possible
763 // sessions tied for top priority. Report this to the user.
764 $list = [];
765 foreach ( $ex->sessionInfos as $info ) {
766 $list[] = $info->getProvider()->describe( $wgContLang );
767 }
768 $list = $wgContLang->listToText( $list );
769 throw new HttpError( 400,
770 Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $wgContLang )->plain()
771 );
772 }
773
774 // Not the one we want, rethrow
775 throw $ex;
776 }
777
778 if ( $session->isPersistent() ) {
779 $wgInitialSessionId = $session->getSessionId();
780 }
781
782 $session->renew();
783 if ( MediaWiki\Session\PHPSessionHandler::isEnabled() &&
784 ( $session->isPersistent() || $session->shouldRememberUser() )
785 ) {
786 // Start the PHP-session for backwards compatibility
787 session_id( $session->getId() );
788 MediaWiki\quietCall( 'session_start' );
789 }
790
791 unset( $session );
792} else {
793 // Even if we didn't set up a global Session, still install our session
794 // handler unless specifically requested not to.
795 if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
796 MediaWiki\Session\PHPSessionHandler::install(
797 MediaWiki\Session\SessionManager::singleton()
798 );
799 }
800}
801Profiler::instance()->scopedProfileOut( $ps_session );
802
806$wgUser = RequestContext::getMain()->getUser(); // BackCompat
807
812
816$wgOut = RequestContext::getMain()->getOutput(); // BackCompat
817
821$wgParser = new StubObject( 'wgParser', $wgParserConf['class'], [ $wgParserConf ] );
822
826$wgTitle = null;
827
828Profiler::instance()->scopedProfileOut( $ps_globals );
829$ps_extensions = Profiler::instance()->scopedProfileIn( $fname . '-extensions' );
830
831// Extension setup functions
832// Entries should be added to this variable during the inclusion
833// of the extension file. This allows the extension to perform
834// any necessary initialisation in the fully initialised environment
835foreach ( $wgExtensionFunctions as $func ) {
836 // Allow closures in PHP 5.3+
837 if ( is_object( $func ) && $func instanceof Closure ) {
838 $profName = $fname . '-extensions-closure';
839 } elseif ( is_array( $func ) ) {
840 if ( is_object( $func[0] ) ) {
841 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
842 } else {
843 $profName = $fname . '-extensions-' . implode( '::', $func );
844 }
845 } else {
846 $profName = $fname . '-extensions-' . strval( $func );
847 }
848
849 $ps_ext_func = Profiler::instance()->scopedProfileIn( $profName );
850 call_user_func( $func );
851 Profiler::instance()->scopedProfileOut( $ps_ext_func );
852}
853
854// If the session user has a 0 id but a valid name, that means we need to
855// autocreate it.
856if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
857 $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
858 if ( $sessionUser->getId() === 0 && User::isValidUserName( $sessionUser->getName() ) ) {
859 $ps_autocreate = Profiler::instance()->scopedProfileIn( $fname . '-autocreate' );
860 $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser(
861 $sessionUser,
862 MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
863 true
864 );
865 Profiler::instance()->scopedProfileOut( $ps_autocreate );
866 \MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [
867 'event' => 'autocreate',
868 'status' => $res,
869 ] );
870 unset( $res );
871 }
872 unset( $sessionUser );
873}
874
875if ( !$wgCommandLineMode ) {
877}
878
879wfDebug( "Fully initialised\n" );
881
882Profiler::instance()->scopedProfileOut( $ps_extensions );
883Profiler::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.
$wgParserConf
Parser configuration.
$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.
$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
$wgSessionsInMemcached
Deprecated alias for $wgSessionsInObjectCache.
$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:829
$messageMemc
Definition Setup.php:692
$parserMemc
Definition Setup.php:693
$wgFileExtensions
Definition Setup.php:421
$wgEnotifWatchlist
Definition Setup.php:341
$ps_memcached
Definition Setup.php:689
$wgEnotifMaxRecips
Definition Setup.php:336
$wgEnotifUserTalk
Definition Setup.php:340
if($wgInvalidateCacheOnLocalSettingsChange) if( $wgNewUserLog) if($wgPageLanguageUseDB) if( $wgCookieSecure==='detect') if($wgProfileOnly) if( $wgMinimalPasswordLength !==false) if($wgMaximalPasswordLength !==false) if(! $wgSessionsInObjectCache &&! $wgSessionsInMemcached) $wgSessionsInObjectCache
Definition Setup.php:477
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
Definition Setup.php:282
$wgUser
Definition Setup.php:806
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:333
$rcMaxAgeDays
Definition Setup.php:265
if( $wgUseFileCache|| $wgUseSquid) $wgHtml5
Definition Setup.php:416
$ps_validation
Definition Setup.php:559
$wgOut
Definition Setup.php:816
$wgCanonicalNamespaceNames
Definitions of the NS_ constants are in Defines.php.
Definition Setup.php:379
$wgMemc
Definition Setup.php:691
$wgParser
Definition Setup.php:821
global $wgCommandLineMode
Definition Setup.php:495
$wgTitle
Definition Setup.php:826
if(!is_object($wgAuth)) if( $wgAuth &&! $wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin) $ps_session
Definition Setup.php:737
$wgEnotifFromEditor
Definition Setup.php:334
$wgJsMimeType
Definition Setup.php:418
$wgUseEnotif
Definition Setup.php:343
$wgEnotifRevealEditorAddress
Definition Setup.php:338
$wgInitialSessionId
Definition Setup.php:742
$wgEnotifImpersonal
Definition Setup.php:335
$wgUsersNotifiedOnAllChanges
Definition Setup.php:345
$wgUserEmailUseReplyTo
Definition Setup.php:344
if(! $wgDBerrorLogTZ) $wgRequest
Definition Setup.php:664
$wgLang
Definition Setup.php:811
$ps_default2
Definition Setup.php:575
$wgContLang
Definition Setup.php:714
$ps_default
Definition Setup.php:51
if($wgLocalInterwiki) if( $wgSharedPrefix===false) if($wgSharedSchema===false) if(! $wgCookiePrefix) $wgCookiePrefix
Definition Setup.php:324
if( $wgServerName !==false) $wgServerName
Definition Setup.php:587
if(is_array( $wgExtraNamespaces)) $wgContLanguageCode
Definition Setup.php:406
$wgEnotifMinorEdits
Definition Setup.php:337
$ps_setup
Definition Setup.php:37
$ps_globals
Definition Setup.php:709
$wgXhtmlDefaultNamespace
Definition Setup.php:417
$wgLockManagers[]
Initialise $wgLockManagers to include basic FS version.
Definition Setup.php:168
$wgEmailAuthentication
Definition Setup.php:332
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
Definition Setup.php:162
if(! $wgEmergencyContact) if(! $wgPasswordSender) if(! $wgNoReplyAddress) if( $wgSecureLogin &&substr( $wgServer, 0, 2) !=='//') $wgVirtualRestConfig['global']['domain']
Definition Setup.php:609
if( $wgCanonicalServer===false) $serverParts
Definition Setup.php:582
$ps_misc
Definition Setup.php:635
if( $wgSkipSkin) $wgSkipSkins[]
Definition Setup.php:296
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:155
$wgEnotifUseRealName
Definition Setup.php:339
$wgFullyInitialised
Definition Setup.php:880
if($wgMetaNamespace===false) if( $wgResourceLoaderMaxQueryLength===false) $wgMinUploadChunkSize
Definition Setup.php:365
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 installHandler()
Install handlers with PHP.
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:61
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
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
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:68
const NS_USER
Definition Defines.php:58
const NS_FILE
Definition Defines.php:62
const CACHE_NONE
Definition Defines.php:94
const NS_MEDIAWIKI_TALK
Definition Defines.php:65
const NS_PROJECT_TALK
Definition Defines.php:61
const NS_MEDIAWIKI
Definition Defines.php:64
const NS_TEMPLATE
Definition Defines.php:66
const NS_SPECIAL
Definition Defines.php:45
const NS_FILE_TALK
Definition Defines.php:63
const NS_HELP_TALK
Definition Defines.php:69
const NS_CATEGORY_TALK
Definition Defines.php:71
const PROTO_HTTP
Definition Defines.php:223
const NS_MEDIA
Definition Defines.php:44
const NS_TALK
Definition Defines.php:57
const NS_USER_TALK
Definition Defines.php:59
const NS_PROJECT
Definition Defines.php:60
const NS_CATEGORY
Definition Defines.php:70
const NS_TEMPLATE_TALK
Definition Defines.php:67
either a plain
Definition hooks.txt:1990
$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:10
const DBO_DEBUG
Definition defines.php:6
$header