Remove $wgFileStore
[lhc/web/wiklou.git] / includes / Setup.php
1 <?php
2 /**
3 * Include most things that are needed to make %MediaWiki work.
4 *
5 * This file is included by WebStart.php and doMaintenance.php so that both
6 * web and maintenance scripts share a final set up phase to include necessary
7 * files and create global object variables.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * This file is not a valid entry point, perform no further processing unless
29 * MEDIAWIKI is defined
30 */
31 if ( !defined( 'MEDIAWIKI' ) ) {
32 exit( 1 );
33 }
34
35 $fname = 'Setup.php';
36 wfProfileIn( $fname );
37 wfProfileIn( $fname . '-defaults' );
38
39 // Check to see if we are at the file scope
40 if ( !isset( $wgVersion ) ) {
41 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
42 die( 1 );
43 }
44
45 // Set various default paths sensibly...
46
47 if ( $wgScript === false ) {
48 $wgScript = "$wgScriptPath/index$wgScriptExtension";
49 }
50 if ( $wgLoadScript === false ) {
51 $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
52 }
53
54 if ( $wgArticlePath === false ) {
55 if ( $wgUsePathInfo ) {
56 $wgArticlePath = "$wgScript/$1";
57 } else {
58 $wgArticlePath = "$wgScript?title=$1";
59 }
60 }
61
62 if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
63 // 'view' is assumed the default action path everywhere in the code
64 // but is rarely filled in $wgActionPaths
65 $wgActionPaths['view'] = $wgArticlePath;
66 }
67
68 if ( $wgStylePath === false ) {
69 $wgStylePath = "$wgScriptPath/skins";
70 }
71 if ( $wgLocalStylePath === false ) {
72 $wgLocalStylePath = "$wgScriptPath/skins";
73 }
74 if ( $wgStyleDirectory === false ) {
75 $wgStyleDirectory = "$IP/skins";
76 }
77 if ( $wgExtensionAssetsPath === false ) {
78 $wgExtensionAssetsPath = "$wgScriptPath/extensions";
79 }
80
81 // Enable default skins. Temporary, to be removed before 1.24 release.
82 // This is hacky and bad, the require_once calls should eventually be generated by the installer
83 // and placed in LocalSettings.php.
84 // While this is in Setup.php, it needs to be done as soon as possible, as some of the setup code
85 // depends on all extensions and skins being already required (bug 67318).
86 require_once "$wgStyleDirectory/MonoBook/MonoBook.php";
87 require_once "$wgStyleDirectory/Vector/Vector.php";
88
89 if ( $wgLogo === false ) {
90 $wgLogo = "$wgStylePath/common/images/wiki.png";
91 }
92
93 if ( $wgUploadPath === false ) {
94 $wgUploadPath = "$wgScriptPath/images";
95 }
96 if ( $wgUploadDirectory === false ) {
97 $wgUploadDirectory = "$IP/images";
98 }
99 if ( $wgReadOnlyFile === false ) {
100 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
101 }
102 if ( $wgFileCacheDirectory === false ) {
103 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
104 }
105 if ( $wgDeletedDirectory === false ) {
106 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
107 }
108
109 if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
110 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
111 }
112
113 if ( isset( $wgFooterIcons['copyright'] )
114 && isset( $wgFooterIcons['copyright']['copyright'] )
115 && $wgFooterIcons['copyright']['copyright'] === array()
116 ) {
117 if ( $wgCopyrightIcon ) {
118 $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
119 } elseif ( $wgRightsIcon || $wgRightsText ) {
120 $wgFooterIcons['copyright']['copyright'] = array(
121 'url' => $wgRightsUrl,
122 'src' => $wgRightsIcon,
123 'alt' => $wgRightsText,
124 );
125 } else {
126 unset( $wgFooterIcons['copyright']['copyright'] );
127 }
128 }
129
130 if ( isset( $wgFooterIcons['poweredby'] )
131 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
132 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
133 ) {
134 $wgFooterIcons['poweredby']['mediawiki']['src'] =
135 "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
136 }
137
138 /**
139 * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
140 * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
141 *
142 * Note that this is the definition of editinterface and it can be granted to
143 * all users if desired.
144 */
145 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
146
147 /**
148 * The canonical names of namespaces 6 and 7 are, as of v1.14, "File"
149 * and "File_talk". The old names "Image" and "Image_talk" are
150 * retained as aliases for backwards compatibility.
151 */
152 $wgNamespaceAliases['Image'] = NS_FILE;
153 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
154
155 /**
156 * Initialise $wgLockManagers to include basic FS version
157 */
158 $wgLockManagers[] = array(
159 'name' => 'fsLockManager',
160 'class' => 'FSLockManager',
161 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
162 );
163 $wgLockManagers[] = array(
164 'name' => 'nullLockManager',
165 'class' => 'NullLockManager',
166 );
167
168 /**
169 * Initialise $wgLocalFileRepo from backwards-compatible settings
170 */
171 if ( !$wgLocalFileRepo ) {
172 $deletedHashLevel = $wgHashedUploadDirectory ? 3 : 0;
173 $wgLocalFileRepo = array(
174 'class' => 'LocalRepo',
175 'name' => 'local',
176 'directory' => $wgUploadDirectory,
177 'scriptDirUrl' => $wgScriptPath,
178 'scriptExtension' => $wgScriptExtension,
179 'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
180 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
181 'thumbScriptUrl' => $wgThumbnailScriptPath,
182 'transformVia404' => !$wgGenerateThumbnailOnParse,
183 'deletedDir' => $wgDeletedDirectory,
184 'deletedHashLevels' => $deletedHashLevel
185 );
186 }
187 /**
188 * Initialise shared repo from backwards-compatible settings
189 */
190 if ( $wgUseSharedUploads ) {
191 if ( $wgSharedUploadDBname ) {
192 $wgForeignFileRepos[] = array(
193 'class' => 'ForeignDBRepo',
194 'name' => 'shared',
195 'directory' => $wgSharedUploadDirectory,
196 'url' => $wgSharedUploadPath,
197 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
198 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
199 'transformVia404' => !$wgGenerateThumbnailOnParse,
200 'dbType' => $wgDBtype,
201 'dbServer' => $wgDBserver,
202 'dbUser' => $wgDBuser,
203 'dbPassword' => $wgDBpassword,
204 'dbName' => $wgSharedUploadDBname,
205 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
206 'tablePrefix' => $wgSharedUploadDBprefix,
207 'hasSharedCache' => $wgCacheSharedUploads,
208 'descBaseUrl' => $wgRepositoryBaseUrl,
209 'fetchDescription' => $wgFetchCommonsDescriptions,
210 );
211 } else {
212 $wgForeignFileRepos[] = array(
213 'class' => 'FileRepo',
214 'name' => 'shared',
215 'directory' => $wgSharedUploadDirectory,
216 'url' => $wgSharedUploadPath,
217 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
218 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
219 'transformVia404' => !$wgGenerateThumbnailOnParse,
220 'descBaseUrl' => $wgRepositoryBaseUrl,
221 'fetchDescription' => $wgFetchCommonsDescriptions,
222 );
223 }
224 }
225 if ( $wgUseInstantCommons ) {
226 $wgForeignFileRepos[] = array(
227 'class' => 'ForeignAPIRepo',
228 'name' => 'wikimediacommons',
229 'apibase' => WebRequest::detectProtocol() === 'https' ?
230 'https://commons.wikimedia.org/w/api.php' :
231 'http://commons.wikimedia.org/w/api.php',
232 'hashLevels' => 2,
233 'fetchDescription' => true,
234 'descriptionCacheExpiry' => 43200,
235 'apiThumbCacheExpiry' => 86400,
236 );
237 }
238 /*
239 * Add on default file backend config for file repos.
240 * FileBackendGroup will handle initializing the backends.
241 */
242 if ( !isset( $wgLocalFileRepo['backend'] ) ) {
243 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
244 }
245 foreach ( $wgForeignFileRepos as &$repo ) {
246 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
247 $repo['directory'] = $wgUploadDirectory; // b/c
248 }
249 if ( !isset( $repo['backend'] ) ) {
250 $repo['backend'] = $repo['name'] . '-backend';
251 }
252 }
253 unset( $repo ); // no global pollution; destroy reference
254
255 if ( $wgRCFilterByAge ) {
256 // Trim down $wgRCLinkDays so that it only lists links which are valid
257 // as determined by $wgRCMaxAge.
258 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
259 sort( $wgRCLinkDays );
260
261 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
262 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
263 // @codingStandardsIgnoreEnd
264 if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
265 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
266 break;
267 }
268 }
269 }
270
271 if ( $wgSkipSkin ) {
272 $wgSkipSkins[] = $wgSkipSkin;
273 }
274
275 if ( $wgLocalInterwiki ) {
276 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
277 }
278
279 // Set default shared prefix
280 if ( $wgSharedPrefix === false ) {
281 $wgSharedPrefix = $wgDBprefix;
282 }
283
284 if ( !$wgCookiePrefix ) {
285 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
286 $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix;
287 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
288 $wgCookiePrefix = $wgSharedDB;
289 } elseif ( $wgDBprefix ) {
290 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
291 } else {
292 $wgCookiePrefix = $wgDBname;
293 }
294 }
295 $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
296
297 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
298
299 if ( $wgMetaNamespace === false ) {
300 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
301 }
302
303 // Default value is either the suhosin limit or -1 for unlimited
304 if ( $wgResourceLoaderMaxQueryLength === false ) {
305 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
306 $wgResourceLoaderMaxQueryLength = $maxValueLength > 0 ? $maxValueLength : -1;
307 }
308
309 /**
310 * Definitions of the NS_ constants are in Defines.php
311 * @private
312 */
313 $wgCanonicalNamespaceNames = array(
314 NS_MEDIA => 'Media',
315 NS_SPECIAL => 'Special',
316 NS_TALK => 'Talk',
317 NS_USER => 'User',
318 NS_USER_TALK => 'User_talk',
319 NS_PROJECT => 'Project',
320 NS_PROJECT_TALK => 'Project_talk',
321 NS_FILE => 'File',
322 NS_FILE_TALK => 'File_talk',
323 NS_MEDIAWIKI => 'MediaWiki',
324 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
325 NS_TEMPLATE => 'Template',
326 NS_TEMPLATE_TALK => 'Template_talk',
327 NS_HELP => 'Help',
328 NS_HELP_TALK => 'Help_talk',
329 NS_CATEGORY => 'Category',
330 NS_CATEGORY_TALK => 'Category_talk',
331 );
332
333 /// @todo UGLY UGLY
334 if ( is_array( $wgExtraNamespaces ) ) {
335 $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
336 }
337
338 // These are now the same, always
339 // To determine the user language, use $wgLang->getCode()
340 $wgContLanguageCode = $wgLanguageCode;
341
342 // Easy to forget to falsify $wgShowIPinHeader for static caches.
343 // If file cache or squid cache is on, just disable this (DWIMD).
344 // Do the same for $wgDebugToolbar.
345 if ( $wgUseFileCache || $wgUseSquid ) {
346 $wgShowIPinHeader = false;
347 $wgDebugToolbar = false;
348 }
349
350 // Doesn't make sense to have if disabled.
351 if ( !$wgEnotifMinorEdits ) {
352 $wgHiddenPrefs[] = 'enotifminoredits';
353 }
354
355 // We always output HTML5 since 1.22, overriding these is no longer supported
356 // we set them here for extensions that depend on its value.
357 $wgHtml5 = true;
358 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
359 $wgJsMimeType = 'text/javascript';
360
361 if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
362 // see http://www.w3.org/TR/rdfa-in-html/#document-conformance
363 if ( $wgMimeType == 'application/xhtml+xml' ) {
364 $wgHtml5Version = 'XHTML+RDFa 1.0';
365 } else {
366 $wgHtml5Version = 'HTML+RDFa 1.0';
367 }
368 }
369
370 // Blacklisted file extensions shouldn't appear on the "allowed" list
371 $wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
372
373 if ( $wgArticleCountMethod === null ) {
374 $wgArticleCountMethod = $wgUseCommaCount ? 'comma' : 'link';
375 }
376
377 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
378 // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged - No GlobalFunction here yet.
379 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
380 // @codingStandardsIgnoreEnd
381 }
382
383 if ( $wgNewUserLog ) {
384 // Add a new log type
385 $wgLogTypes[] = 'newusers';
386 $wgLogNames['newusers'] = 'newuserlogpage';
387 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
388 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
389 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
390 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
391 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
392 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
393 }
394
395 if ( $wgPageLanguageUseDB ) {
396 $wgLogTypes[] = 'pagelang';
397 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
398 }
399
400 if ( $wgCookieSecure === 'detect' ) {
401 $wgCookieSecure = ( WebRequest::detectProtocol() === 'https' );
402 }
403
404 if ( $wgRC2UDPAddress ) {
405 $wgRCFeeds['default'] = array(
406 'formatter' => 'IRCColourfulRCFeedFormatter',
407 'uri' => "udp://$wgRC2UDPAddress:$wgRC2UDPPort/$wgRC2UDPPrefix",
408 'add_interwiki_prefix' => &$wgRC2UDPInterwikiPrefix,
409 'omit_bots' => &$wgRC2UDPOmitBots,
410 );
411 }
412
413 wfProfileOut( $fname . '-defaults' );
414
415 // Disable MWDebug for command line mode, this prevents MWDebug from eating up
416 // all the memory from logging SQL queries on maintenance scripts
417 global $wgCommandLineMode;
418 if ( $wgDebugToolbar && !$wgCommandLineMode ) {
419 wfProfileIn( $fname . '-debugtoolbar' );
420 MWDebug::init();
421 wfProfileOut( $fname . '-debugtoolbar' );
422 }
423
424 if ( !class_exists( 'AutoLoader' ) ) {
425 require_once "$IP/includes/AutoLoader.php";
426 }
427
428 wfProfileIn( $fname . '-exception' );
429 MWExceptionHandler::installHandler();
430 wfProfileOut( $fname . '-exception' );
431
432 wfProfileIn( $fname . '-includes' );
433 require_once "$IP/includes/normal/UtfNormalUtil.php";
434 require_once "$IP/includes/GlobalFunctions.php";
435 require_once "$IP/includes/normal/UtfNormalDefines.php";
436 wfProfileOut( $fname . '-includes' );
437
438 wfProfileIn( $fname . '-defaults2' );
439
440 if ( $wgCanonicalServer === false ) {
441 $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
442 }
443
444 // Set server name
445 $serverParts = wfParseUrl( $wgCanonicalServer );
446 if ( $wgServerName !== false ) {
447 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
448 . 'not customized. Overwriting $wgServerName.' );
449 }
450 $wgServerName = $serverParts['host'];
451 unset( $serverParts );
452
453 // Set defaults for configuration variables
454 // that are derived from the server name by default
455 if ( $wgEmergencyContact === false ) {
456 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
457 }
458
459 if ( $wgPasswordSender === false ) {
460 $wgPasswordSender = 'apache@' . $wgServerName;
461 }
462
463 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
464 $wgSecureLogin = false;
465 wfWarn( 'Secure login was enabled on a server that only supports '
466 . 'HTTP or HTTPS. Disabling secure login.' );
467 }
468
469 // Now that GlobalFunctions is loaded, set defaults that depend
470 // on it.
471 if ( $wgTmpDirectory === false ) {
472 wfProfileIn( $fname . '-tempDir' );
473 $wgTmpDirectory = wfTempDir();
474 wfProfileOut( $fname . '-tempDir' );
475 }
476
477 // $wgHTCPMulticastRouting got renamed to $wgHTCPRouting in MediaWiki 1.22
478 // ensure back compatibility.
479 if ( !$wgHTCPRouting && $wgHTCPMulticastRouting ) {
480 $wgHTCPRouting = $wgHTCPMulticastRouting;
481 }
482
483 // Initialize $wgHTCPRouting from backwards-compatible settings that
484 // comes from pre 1.20 version.
485 if ( !$wgHTCPRouting && $wgHTCPMulticastAddress ) {
486 $wgHTCPRouting = array(
487 '' => array(
488 'host' => $wgHTCPMulticastAddress,
489 'port' => $wgHTCPPort,
490 )
491 );
492 }
493
494 // Back compatibility for $wgRateLimitLog deprecated with 1.23
495 if ( $wgRateLimitLog && ! array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
496 $wgDebugLogGroups['ratelimit'] = $wgRateLimitLog;
497 }
498
499 if ( $wgProfileOnly ) {
500 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
501 $wgDebugLogFile = '';
502 }
503
504 wfProfileOut( $fname . '-defaults2' );
505 wfProfileIn( $fname . '-misc1' );
506
507 // Raise the memory limit if it's too low
508 wfMemoryLimit();
509
510 /**
511 * Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
512 * that happens whenever you use a date function without the timezone being
513 * explicitly set. Inspired by phpMyAdmin's treatment of the problem.
514 */
515 if ( is_null( $wgLocaltimezone ) ) {
516 wfSuppressWarnings();
517 $wgLocaltimezone = date_default_timezone_get();
518 wfRestoreWarnings();
519 }
520
521 date_default_timezone_set( $wgLocaltimezone );
522 if ( is_null( $wgLocalTZoffset ) ) {
523 $wgLocalTZoffset = date( 'Z' ) / 60;
524 }
525
526 // Useful debug output
527 if ( $wgCommandLineMode ) {
528 $wgRequest = new FauxRequest( array() );
529
530 wfDebug( "\n\nStart command line script $self\n" );
531 } else {
532 // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
533 $wgRequest = new WebRequest;
534
535 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
536
537 if ( $wgDebugPrintHttpHeaders ) {
538 $debug .= "HTTP HEADERS:\n";
539
540 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
541 $debug .= "$name: $value\n";
542 }
543 }
544 wfDebug( $debug );
545 }
546
547 wfProfileOut( $fname . '-misc1' );
548 wfProfileIn( $fname . '-memcached' );
549
550 $wgMemc = wfGetMainCache();
551 $messageMemc = wfGetMessageCacheStorage();
552 $parserMemc = wfGetParserCacheStorage();
553 $wgLangConvMemc = wfGetLangConverterCacheStorage();
554
555 wfDebugLog( 'caches', 'main: ' . get_class( $wgMemc ) .
556 ', message: ' . get_class( $messageMemc ) .
557 ', parser: ' . get_class( $parserMemc ) );
558
559 wfProfileOut( $fname . '-memcached' );
560
561 // Most of the config is out, some might want to run hooks here.
562 wfRunHooks( 'SetupAfterCache' );
563
564 wfProfileIn( $fname . '-session' );
565
566 // If session.auto_start is there, we can't touch session name
567 if ( !wfIniGetBool( 'session.auto_start' ) ) {
568 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
569 }
570
571 if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode &&
572 ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) )
573 ) {
574 wfSetupSession();
575 }
576
577 wfProfileOut( $fname . '-session' );
578 wfProfileIn( $fname . '-globals' );
579
580 /**
581 * @var Language $wgContLang
582 */
583 $wgContLang = Language::factory( $wgLanguageCode );
584 $wgContLang->initEncoding();
585 $wgContLang->initContLang();
586
587 // Now that variant lists may be available...
588 $wgRequest->interpolateTitle();
589
590 /**
591 * @var User $wgUser
592 */
593 $wgUser = RequestContext::getMain()->getUser(); // BackCompat
594
595 /**
596 * @var Language $wgLang
597 */
598 $wgLang = new StubUserLang;
599
600 /**
601 * @var OutputPage $wgOut
602 */
603 $wgOut = RequestContext::getMain()->getOutput(); // BackCompat
604
605 /**
606 * @var Parser $wgParser
607 */
608 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
609
610 if ( !is_object( $wgAuth ) ) {
611 $wgAuth = new AuthPlugin;
612 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
613 }
614
615 /**
616 * @var Title $wgTitle
617 */
618 $wgTitle = null;
619
620 $wgDeferredUpdateList = array();
621
622 // Disable all other email settings automatically if $wgEnableEmail
623 // is set to false. - bug 63678
624 if ( !$wgEnableEmail ) {
625 $wgAllowHTMLEmail = false;
626 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
627 $wgEnableUserEmail = false;
628 $wgEnotifFromEditor = false;
629 $wgEnotifImpersonal = false;
630 $wgEnotifMaxRecips = 0;
631 $wgEnotifMinorEdits = false;
632 $wgEnotifRevealEditorAddress = false;
633 $wgEnotifUseJobQ = false;
634 $wgEnotifUseRealName = false;
635 $wgEnotifUserTalk = false;
636 $wgEnotifWatchlist = false;
637 unset( $wgGroupPermissions['user']['sendemail'] );
638 $wgUserEmailUseReplyTo = false;
639 $wgUsersNotifiedOnAllChanges = array();
640 }
641
642 wfProfileOut( $fname . '-globals' );
643 wfProfileIn( $fname . '-extensions' );
644
645 // Extension setup functions for extensions other than skins
646 // Entries should be added to this variable during the inclusion
647 // of the extension file. This allows the extension to perform
648 // any necessary initialisation in the fully initialised environment
649 foreach ( $wgExtensionFunctions as $func ) {
650 // Allow closures in PHP 5.3+
651 if ( is_object( $func ) && $func instanceof Closure ) {
652 $profName = $fname . '-extensions-closure';
653 } elseif ( is_array( $func ) ) {
654 if ( is_object( $func[0] ) ) {
655 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
656 } else {
657 $profName = $fname . '-extensions-' . implode( '::', $func );
658 }
659 } else {
660 $profName = $fname . '-extensions-' . strval( $func );
661 }
662
663 wfProfileIn( $profName );
664 call_user_func( $func );
665 wfProfileOut( $profName );
666 }
667
668 wfDebug( "Fully initialised\n" );
669 $wgFullyInitialised = true;
670
671 wfProfileOut( $fname . '-extensions' );
672 wfProfileOut( $fname );