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