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