Merge "resourceloader: Condition-wrap the HTML tag instead of JS response"
[mediawiki.git] / includes / Setup.php
blob8b2138bd3671818e218ec0ab6e1f97759cabc075
1 <?php
2 /**
3 * Include most things that are needed to make %MediaWiki work.
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.
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.
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.
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
24 * @file
27 /**
28 * This file is not a valid entry point, perform no further processing unless
29 * MEDIAWIKI is defined
31 if ( !defined( 'MEDIAWIKI' ) ) {
32 exit( 1 );
35 $fname = 'Setup.php';
36 wfProfileIn( $fname );
37 wfProfileIn( $fname . '-defaults' );
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 );
45 // Set various default paths sensibly...
47 if ( $wgScript === false ) {
48 $wgScript = "$wgScriptPath/index$wgScriptExtension";
50 if ( $wgLoadScript === false ) {
51 $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
54 if ( $wgArticlePath === false ) {
55 if ( $wgUsePathInfo ) {
56 $wgArticlePath = "$wgScript/$1";
57 } else {
58 $wgArticlePath = "$wgScript?title=$1";
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;
68 if ( $wgStylePath === false ) {
69 $wgStylePath = "$wgScriptPath/skins";
71 if ( $wgLocalStylePath === false ) {
72 $wgLocalStylePath = "$wgScriptPath/skins";
74 if ( $wgStyleDirectory === false ) {
75 $wgStyleDirectory = "$IP/skins";
77 if ( $wgExtensionAssetsPath === false ) {
78 $wgExtensionAssetsPath = "$wgScriptPath/extensions";
81 if ( $wgLogo === false ) {
82 $wgLogo = "$wgStylePath/common/images/wiki.png";
85 if ( $wgUploadPath === false ) {
86 $wgUploadPath = "$wgScriptPath/images";
88 if ( $wgUploadDirectory === false ) {
89 $wgUploadDirectory = "$IP/images";
91 if ( $wgReadOnlyFile === false ) {
92 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
94 if ( $wgFileCacheDirectory === false ) {
95 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
97 if ( $wgDeletedDirectory === false ) {
98 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
101 if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
102 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
105 if ( isset( $wgFooterIcons['copyright'] )
106 && isset( $wgFooterIcons['copyright']['copyright'] )
107 && $wgFooterIcons['copyright']['copyright'] === array()
109 if ( $wgCopyrightIcon ) {
110 $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
111 } elseif ( $wgRightsIcon || $wgRightsText ) {
112 $wgFooterIcons['copyright']['copyright'] = array(
113 'url' => $wgRightsUrl,
114 'src' => $wgRightsIcon,
115 'alt' => $wgRightsText,
117 } else {
118 unset( $wgFooterIcons['copyright']['copyright'] );
122 if ( isset( $wgFooterIcons['poweredby'] )
123 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
124 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
126 $wgFooterIcons['poweredby']['mediawiki']['src'] =
127 "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
131 * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
132 * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
134 * Note that this is the definition of editinterface and it can be granted to
135 * all users if desired.
137 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
140 * The canonical names of namespaces 6 and 7 are, as of v1.14, "File"
141 * and "File_talk". The old names "Image" and "Image_talk" are
142 * retained as aliases for backwards compatibility.
144 $wgNamespaceAliases['Image'] = NS_FILE;
145 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
148 * Initialise $wgLockManagers to include basic FS version
150 $wgLockManagers[] = array(
151 'name' => 'fsLockManager',
152 'class' => 'FSLockManager',
153 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
155 $wgLockManagers[] = array(
156 'name' => 'nullLockManager',
157 'class' => 'NullLockManager',
161 * Initialise $wgLocalFileRepo from backwards-compatible settings
163 if ( !$wgLocalFileRepo ) {
164 $wgLocalFileRepo = array(
165 'class' => 'LocalRepo',
166 'name' => 'local',
167 'directory' => $wgUploadDirectory,
168 'scriptDirUrl' => $wgScriptPath,
169 'scriptExtension' => $wgScriptExtension,
170 'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
171 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
172 'thumbScriptUrl' => $wgThumbnailScriptPath,
173 'transformVia404' => !$wgGenerateThumbnailOnParse,
174 'deletedDir' => $wgDeletedDirectory,
175 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0
179 * Initialise shared repo from backwards-compatible settings
181 if ( $wgUseSharedUploads ) {
182 if ( $wgSharedUploadDBname ) {
183 $wgForeignFileRepos[] = array(
184 'class' => 'ForeignDBRepo',
185 'name' => 'shared',
186 'directory' => $wgSharedUploadDirectory,
187 'url' => $wgSharedUploadPath,
188 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
189 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
190 'transformVia404' => !$wgGenerateThumbnailOnParse,
191 'dbType' => $wgDBtype,
192 'dbServer' => $wgDBserver,
193 'dbUser' => $wgDBuser,
194 'dbPassword' => $wgDBpassword,
195 'dbName' => $wgSharedUploadDBname,
196 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
197 'tablePrefix' => $wgSharedUploadDBprefix,
198 'hasSharedCache' => $wgCacheSharedUploads,
199 'descBaseUrl' => $wgRepositoryBaseUrl,
200 'fetchDescription' => $wgFetchCommonsDescriptions,
202 } else {
203 $wgForeignFileRepos[] = array(
204 'class' => 'FileRepo',
205 'name' => 'shared',
206 'directory' => $wgSharedUploadDirectory,
207 'url' => $wgSharedUploadPath,
208 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
209 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
210 'transformVia404' => !$wgGenerateThumbnailOnParse,
211 'descBaseUrl' => $wgRepositoryBaseUrl,
212 'fetchDescription' => $wgFetchCommonsDescriptions,
216 if ( $wgUseInstantCommons ) {
217 $wgForeignFileRepos[] = array(
218 'class' => 'ForeignAPIRepo',
219 'name' => 'wikimediacommons',
220 'apibase' => WebRequest::detectProtocol() === 'https' ?
221 'https://commons.wikimedia.org/w/api.php' :
222 'http://commons.wikimedia.org/w/api.php',
223 'hashLevels' => 2,
224 'fetchDescription' => true,
225 'descriptionCacheExpiry' => 43200,
226 'apiThumbCacheExpiry' => 86400,
230 * Add on default file backend config for file repos.
231 * FileBackendGroup will handle initializing the backends.
233 if ( !isset( $wgLocalFileRepo['backend'] ) ) {
234 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
236 foreach ( $wgForeignFileRepos as &$repo ) {
237 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
238 $repo['directory'] = $wgUploadDirectory; // b/c
240 if ( !isset( $repo['backend'] ) ) {
241 $repo['backend'] = $repo['name'] . '-backend';
244 unset( $repo ); // no global pollution; destroy reference
246 if ( $wgRCFilterByAge ) {
247 // Trim down $wgRCLinkDays so that it only lists links which are valid
248 // as determined by $wgRCMaxAge.
249 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
250 sort( $wgRCLinkDays );
252 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
253 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
254 // @codingStandardsIgnoreEnd
255 if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
256 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
257 break;
262 if ( $wgSkipSkin ) {
263 $wgSkipSkins[] = $wgSkipSkin;
266 // Register skins
267 // Use a closure to avoid leaking into global state
268 call_user_func( function () use ( $wgValidSkinNames ) {
269 $factory = SkinFactory::getDefaultInstance();
270 foreach ( $wgValidSkinNames as $name => $skin ) {
271 $factory->register( $name, $skin, function () use ( $name, $skin ) {
272 $class = "Skin$skin";
273 return new $class( $name );
274 } );
276 // Register a hidden "fallback" skin
277 $factory->register( 'fallback', 'Fallback', function () {
278 return new SkinFallback;
279 } );
280 } );
281 $wgSkipSkins[] = 'fallback';
283 if ( $wgLocalInterwiki ) {
284 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
287 // Set default shared prefix
288 if ( $wgSharedPrefix === false ) {
289 $wgSharedPrefix = $wgDBprefix;
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;
303 $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
305 if ( $wgEnableEmail ) {
306 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
307 } else {
308 // Disable all other email settings automatically if $wgEnableEmail
309 // is set to false. - bug 63678
310 $wgAllowHTMLEmail = false;
311 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
312 $wgEnableUserEmail = false;
313 $wgEnotifFromEditor = false;
314 $wgEnotifImpersonal = false;
315 $wgEnotifMaxRecips = 0;
316 $wgEnotifMinorEdits = false;
317 $wgEnotifRevealEditorAddress = false;
318 $wgEnotifUseJobQ = false;
319 $wgEnotifUseRealName = false;
320 $wgEnotifUserTalk = false;
321 $wgEnotifWatchlist = false;
322 unset( $wgGroupPermissions['user']['sendemail'] );
323 $wgUseEnotif = false;
324 $wgUserEmailUseReplyTo = false;
325 $wgUsersNotifiedOnAllChanges = array();
328 // Doesn't make sense to have if disabled.
329 if ( !$wgEnotifMinorEdits ) {
330 $wgHiddenPrefs[] = 'enotifminoredits';
333 if ( $wgMetaNamespace === false ) {
334 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
337 // Default value is either the suhosin limit or -1 for unlimited
338 if ( $wgResourceLoaderMaxQueryLength === false ) {
339 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
340 $wgResourceLoaderMaxQueryLength = $maxValueLength > 0 ? $maxValueLength : -1;
344 * Definitions of the NS_ constants are in Defines.php
345 * @private
347 $wgCanonicalNamespaceNames = array(
348 NS_MEDIA => 'Media',
349 NS_SPECIAL => 'Special',
350 NS_TALK => 'Talk',
351 NS_USER => 'User',
352 NS_USER_TALK => 'User_talk',
353 NS_PROJECT => 'Project',
354 NS_PROJECT_TALK => 'Project_talk',
355 NS_FILE => 'File',
356 NS_FILE_TALK => 'File_talk',
357 NS_MEDIAWIKI => 'MediaWiki',
358 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
359 NS_TEMPLATE => 'Template',
360 NS_TEMPLATE_TALK => 'Template_talk',
361 NS_HELP => 'Help',
362 NS_HELP_TALK => 'Help_talk',
363 NS_CATEGORY => 'Category',
364 NS_CATEGORY_TALK => 'Category_talk',
367 /// @todo UGLY UGLY
368 if ( is_array( $wgExtraNamespaces ) ) {
369 $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
372 // These are now the same, always
373 // To determine the user language, use $wgLang->getCode()
374 $wgContLanguageCode = $wgLanguageCode;
376 // Easy to forget to falsify $wgShowIPinHeader for static caches.
377 // If file cache or squid cache is on, just disable this (DWIMD).
378 // Do the same for $wgDebugToolbar.
379 if ( $wgUseFileCache || $wgUseSquid ) {
380 $wgShowIPinHeader = false;
381 $wgDebugToolbar = false;
384 // We always output HTML5 since 1.22, overriding these is no longer supported
385 // we set them here for extensions that depend on its value.
386 $wgHtml5 = true;
387 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
388 $wgJsMimeType = 'text/javascript';
390 if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
391 // see http://www.w3.org/TR/rdfa-in-html/#document-conformance
392 if ( $wgMimeType == 'application/xhtml+xml' ) {
393 $wgHtml5Version = 'XHTML+RDFa 1.0';
394 } else {
395 $wgHtml5Version = 'HTML+RDFa 1.0';
399 // Blacklisted file extensions shouldn't appear on the "allowed" list
400 $wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
402 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
403 // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged - No GlobalFunction here yet.
404 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
405 // @codingStandardsIgnoreEnd
408 if ( $wgNewUserLog ) {
409 // Add a new log type
410 $wgLogTypes[] = 'newusers';
411 $wgLogNames['newusers'] = 'newuserlogpage';
412 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
413 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
414 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
415 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
416 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
417 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
420 if ( $wgPageLanguageUseDB ) {
421 $wgLogTypes[] = 'pagelang';
422 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
425 if ( $wgCookieSecure === 'detect' ) {
426 $wgCookieSecure = ( WebRequest::detectProtocol() === 'https' );
429 // Back compatibility for $wgRateLimitLog deprecated with 1.23
430 if ( $wgRateLimitLog && !array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
431 $wgDebugLogGroups['ratelimit'] = $wgRateLimitLog;
434 if ( $wgProfileOnly ) {
435 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
436 $wgDebugLogFile = '';
439 wfProfileOut( $fname . '-defaults' );
441 // Disable MWDebug for command line mode, this prevents MWDebug from eating up
442 // all the memory from logging SQL queries on maintenance scripts
443 global $wgCommandLineMode;
444 if ( $wgDebugToolbar && !$wgCommandLineMode ) {
445 wfProfileIn( $fname . '-debugtoolbar' );
446 MWDebug::init();
447 wfProfileOut( $fname . '-debugtoolbar' );
450 if ( !class_exists( 'AutoLoader' ) ) {
451 require_once "$IP/includes/AutoLoader.php";
454 wfProfileIn( $fname . '-exception' );
455 MWExceptionHandler::installHandler();
456 wfProfileOut( $fname . '-exception' );
458 wfProfileIn( $fname . '-includes' );
459 require_once "$IP/includes/normal/UtfNormalUtil.php";
460 require_once "$IP/includes/GlobalFunctions.php";
461 require_once "$IP/includes/normal/UtfNormalDefines.php";
462 wfProfileOut( $fname . '-includes' );
464 wfProfileIn( $fname . '-defaults2' );
466 if ( $wgCanonicalServer === false ) {
467 $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
470 // Set server name
471 $serverParts = wfParseUrl( $wgCanonicalServer );
472 if ( $wgServerName !== false ) {
473 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
474 . 'not customized. Overwriting $wgServerName.' );
476 $wgServerName = $serverParts['host'];
477 unset( $serverParts );
479 // Set defaults for configuration variables
480 // that are derived from the server name by default
481 if ( $wgEmergencyContact === false ) {
482 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
485 if ( $wgPasswordSender === false ) {
486 $wgPasswordSender = 'apache@' . $wgServerName;
489 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
490 $wgSecureLogin = false;
491 wfWarn( 'Secure login was enabled on a server that only supports '
492 . 'HTTP or HTTPS. Disabling secure login.' );
495 // Now that GlobalFunctions is loaded, set defaults that depend
496 // on it.
497 if ( $wgTmpDirectory === false ) {
498 wfProfileIn( $fname . '-tempDir' );
499 $wgTmpDirectory = wfTempDir();
500 wfProfileOut( $fname . '-tempDir' );
503 wfProfileOut( $fname . '-defaults2' );
504 wfProfileIn( $fname . '-misc1' );
506 // Raise the memory limit if it's too low
507 wfMemoryLimit();
510 * Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
511 * that happens whenever you use a date function without the timezone being
512 * explicitly set. Inspired by phpMyAdmin's treatment of the problem.
514 if ( is_null( $wgLocaltimezone ) ) {
515 wfSuppressWarnings();
516 $wgLocaltimezone = date_default_timezone_get();
517 wfRestoreWarnings();
520 date_default_timezone_set( $wgLocaltimezone );
521 if ( is_null( $wgLocalTZoffset ) ) {
522 $wgLocalTZoffset = date( 'Z' ) / 60;
525 // Useful debug output
526 if ( $wgCommandLineMode ) {
527 $wgRequest = new FauxRequest( array() );
529 wfDebug( "\n\nStart command line script $self\n" );
530 } else {
531 // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
532 $wgRequest = new WebRequest;
534 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
536 if ( $wgDebugPrintHttpHeaders ) {
537 $debug .= "HTTP HEADERS:\n";
539 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
540 $debug .= "$name: $value\n";
543 wfDebug( $debug );
546 wfProfileOut( $fname . '-misc1' );
547 wfProfileIn( $fname . '-memcached' );
549 $wgMemc = wfGetMainCache();
550 $messageMemc = wfGetMessageCacheStorage();
551 $parserMemc = wfGetParserCacheStorage();
552 $wgLangConvMemc = wfGetLangConverterCacheStorage();
554 wfDebugLog( 'caches', 'main: ' . get_class( $wgMemc ) .
555 ', message: ' . get_class( $messageMemc ) .
556 ', parser: ' . get_class( $parserMemc ) );
558 wfProfileOut( $fname . '-memcached' );
560 // Most of the config is out, some might want to run hooks here.
561 wfRunHooks( 'SetupAfterCache' );
563 wfProfileIn( $fname . '-session' );
565 if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
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' );
571 if ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) ) {
572 wfSetupSession();
576 wfProfileOut( $fname . '-session' );
577 wfProfileIn( $fname . '-globals' );
580 * @var Language $wgContLang
582 $wgContLang = Language::factory( $wgLanguageCode );
583 $wgContLang->initEncoding();
584 $wgContLang->initContLang();
586 // Now that variant lists may be available...
587 $wgRequest->interpolateTitle();
590 * @var User $wgUser
592 $wgUser = RequestContext::getMain()->getUser(); // BackCompat
595 * @var Language $wgLang
597 $wgLang = new StubUserLang;
600 * @var OutputPage $wgOut
602 $wgOut = RequestContext::getMain()->getOutput(); // BackCompat
605 * @var Parser $wgParser
607 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
609 if ( !is_object( $wgAuth ) ) {
610 $wgAuth = new AuthPlugin;
611 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
615 * @var Title $wgTitle
617 $wgTitle = null;
620 * @deprecated since 1.24 Use DeferredUpdates::addUpdate instead
621 * @var array
623 $wgDeferredUpdateList = array();
625 wfProfileOut( $fname . '-globals' );
626 wfProfileIn( $fname . '-extensions' );
628 // Extension setup functions for extensions other than skins
629 // Entries should be added to this variable during the inclusion
630 // of the extension file. This allows the extension to perform
631 // any necessary initialisation in the fully initialised environment
632 foreach ( $wgExtensionFunctions as $func ) {
633 // Allow closures in PHP 5.3+
634 if ( is_object( $func ) && $func instanceof Closure ) {
635 $profName = $fname . '-extensions-closure';
636 } elseif ( is_array( $func ) ) {
637 if ( is_object( $func[0] ) ) {
638 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
639 } else {
640 $profName = $fname . '-extensions-' . implode( '::', $func );
642 } else {
643 $profName = $fname . '-extensions-' . strval( $func );
646 wfProfileIn( $profName );
647 call_user_func( $func );
648 wfProfileOut( $profName );
651 wfDebug( "Fully initialised\n" );
652 $wgFullyInitialised = true;
654 wfProfileOut( $fname . '-extensions' );
655 wfProfileOut( $fname );