Merge "Move VectorBeta modules to VectorBeta extension"
[lhc/web/wiklou.git] / includes / Setup.php
1 <?php
2 /**
3 * Include most things that's need to customize the site.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 /**
24 * This file is not a valid entry point, perform no further processing unless
25 * MEDIAWIKI is defined
26 */
27 if ( !defined( 'MEDIAWIKI' ) ) {
28 exit( 1 );
29 }
30
31 # The main wiki script and things like database
32 # conversion and maintenance scripts all share a
33 # common setup of including lots of classes and
34 # setting up a few globals.
35 #
36
37 $fname = 'Setup.php';
38 wfProfileIn( $fname );
39 wfProfileIn( $fname . '-defaults' );
40
41 // Check to see if we are at the file scope
42 if ( !isset( $wgVersion ) ) {
43 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
44 die( 1 );
45 }
46
47 // Set various default paths sensibly...
48 if ( $wgScript === false ) {
49 $wgScript = "$wgScriptPath/index$wgScriptExtension";
50 }
51 if ( $wgLoadScript === false ) {
52 $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
53 }
54
55 if ( $wgArticlePath === false ) {
56 if ( $wgUsePathInfo ) {
57 $wgArticlePath = "$wgScript/$1";
58 } else {
59 $wgArticlePath = "$wgScript?title=$1";
60 }
61 }
62
63 if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
64 # 'view' is assumed the default action path everywhere in the code
65 # but is rarely filled in $wgActionPaths
66 $wgActionPaths['view'] = $wgArticlePath;
67 }
68
69 if ( $wgStylePath === false ) {
70 $wgStylePath = "$wgScriptPath/skins";
71 }
72 if ( $wgLocalStylePath === false ) {
73 $wgLocalStylePath = "$wgScriptPath/skins";
74 }
75 if ( $wgStyleDirectory === false ) {
76 $wgStyleDirectory = "$IP/skins";
77 }
78 if ( $wgExtensionAssetsPath === false ) {
79 $wgExtensionAssetsPath = "$wgScriptPath/extensions";
80 }
81
82 if ( $wgLogo === false ) {
83 $wgLogo = "$wgStylePath/common/images/wiki.png";
84 }
85
86 if ( $wgUploadPath === false ) {
87 $wgUploadPath = "$wgScriptPath/images";
88 }
89 if ( $wgUploadDirectory === false ) {
90 $wgUploadDirectory = "$IP/images";
91 }
92 if ( $wgReadOnlyFile === false ) {
93 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
94 }
95 if ( $wgFileCacheDirectory === false ) {
96 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
97 }
98 if ( $wgDeletedDirectory === false ) {
99 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
100 }
101
102 if ( isset( $wgFileStore['deleted']['directory'] ) ) {
103 $wgDeletedDirectory = $wgFileStore['deleted']['directory'];
104 }
105
106 if ( isset( $wgFooterIcons['copyright'] )
107 && isset( $wgFooterIcons['copyright']['copyright'] )
108 && $wgFooterIcons['copyright']['copyright'] === array()
109 ) {
110 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
111 $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
112 } elseif ( $wgRightsIcon || $wgRightsText ) {
113 $wgFooterIcons['copyright']['copyright'] = array(
114 'url' => $wgRightsUrl,
115 'src' => $wgRightsIcon,
116 'alt' => $wgRightsText,
117 );
118 } else {
119 unset( $wgFooterIcons['copyright']['copyright'] );
120 }
121 }
122
123 if ( isset( $wgFooterIcons['poweredby'] )
124 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
125 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
126 ) {
127 $wgFooterIcons['poweredby']['mediawiki']['src'] = "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
128 }
129
130 /**
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.
133 *
134 * Note that this is the definition of editinterface and it can be granted to
135 * all users if desired.
136 */
137 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
138
139 /**
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.
143 */
144 $wgNamespaceAliases['Image'] = NS_FILE;
145 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
146
147 /**
148 * Initialise $wgLockManagers to include basic FS version
149 */
150 $wgLockManagers[] = array(
151 'name' => 'fsLockManager',
152 'class' => 'FSLockManager',
153 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
154 );
155 $wgLockManagers[] = array(
156 'name' => 'nullLockManager',
157 'class' => 'NullLockManager',
158 );
159
160 /**
161 * Initialise $wgLocalFileRepo from backwards-compatible settings
162 */
163 if ( !$wgLocalFileRepo ) {
164 if ( isset( $wgFileStore['deleted']['hash'] ) ) {
165 $deletedHashLevel = $wgFileStore['deleted']['hash'];
166 } else {
167 $deletedHashLevel = $wgHashedUploadDirectory ? 3 : 0;
168 }
169 $wgLocalFileRepo = array(
170 'class' => 'LocalRepo',
171 'name' => 'local',
172 'directory' => $wgUploadDirectory,
173 'scriptDirUrl' => $wgScriptPath,
174 'scriptExtension' => $wgScriptExtension,
175 'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
176 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
177 'thumbScriptUrl' => $wgThumbnailScriptPath,
178 'transformVia404' => !$wgGenerateThumbnailOnParse,
179 'deletedDir' => $wgDeletedDirectory,
180 'deletedHashLevels' => $deletedHashLevel
181 );
182 }
183 /**
184 * Initialise shared repo from backwards-compatible settings
185 */
186 if ( $wgUseSharedUploads ) {
187 if ( $wgSharedUploadDBname ) {
188 $wgForeignFileRepos[] = array(
189 'class' => 'ForeignDBRepo',
190 'name' => 'shared',
191 'directory' => $wgSharedUploadDirectory,
192 'url' => $wgSharedUploadPath,
193 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
194 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
195 'transformVia404' => !$wgGenerateThumbnailOnParse,
196 'dbType' => $wgDBtype,
197 'dbServer' => $wgDBserver,
198 'dbUser' => $wgDBuser,
199 'dbPassword' => $wgDBpassword,
200 'dbName' => $wgSharedUploadDBname,
201 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
202 'tablePrefix' => $wgSharedUploadDBprefix,
203 'hasSharedCache' => $wgCacheSharedUploads,
204 'descBaseUrl' => $wgRepositoryBaseUrl,
205 'fetchDescription' => $wgFetchCommonsDescriptions,
206 );
207 } else {
208 $wgForeignFileRepos[] = array(
209 'class' => 'FileRepo',
210 'name' => 'shared',
211 'directory' => $wgSharedUploadDirectory,
212 'url' => $wgSharedUploadPath,
213 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
214 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
215 'transformVia404' => !$wgGenerateThumbnailOnParse,
216 'descBaseUrl' => $wgRepositoryBaseUrl,
217 'fetchDescription' => $wgFetchCommonsDescriptions,
218 );
219 }
220 }
221 if ( $wgUseInstantCommons ) {
222 $wgForeignFileRepos[] = array(
223 'class' => 'ForeignAPIRepo',
224 'name' => 'wikimediacommons',
225 'apibase' => WebRequest::detectProtocol() === 'https' ?
226 'https://commons.wikimedia.org/w/api.php' :
227 'http://commons.wikimedia.org/w/api.php',
228 'hashLevels' => 2,
229 'fetchDescription' => true,
230 'descriptionCacheExpiry' => 43200,
231 'apiThumbCacheExpiry' => 86400,
232 );
233 }
234 /*
235 * Add on default file backend config for file repos.
236 * FileBackendGroup will handle initializing the backends.
237 */
238 if ( !isset( $wgLocalFileRepo['backend'] ) ) {
239 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
240 }
241 foreach ( $wgForeignFileRepos as &$repo ) {
242 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
243 $repo['directory'] = $wgUploadDirectory; // b/c
244 }
245 if ( !isset( $repo['backend'] ) ) {
246 $repo['backend'] = $repo['name'] . '-backend';
247 }
248 }
249 unset( $repo ); // no global pollution; destroy reference
250
251 if ( is_null( $wgEnableAutoRotation ) ) {
252 wfProfileIn( $fname . '-defaults-rotation' );
253 // Only enable auto-rotation when the bitmap handler can rotate
254 $wgEnableAutoRotation = BitmapHandler::canRotate();
255 wfProfileOut( $fname . '-defaults-rotation' );
256 }
257
258 if ( $wgRCFilterByAge ) {
259 # # Trim down $wgRCLinkDays so that it only lists links which are valid
260 # # as determined by $wgRCMaxAge.
261 # # Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
262 sort( $wgRCLinkDays );
263 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
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 # Set default shared prefix
276 if ( $wgSharedPrefix === false ) {
277 $wgSharedPrefix = $wgDBprefix;
278 }
279
280 if ( !$wgCookiePrefix ) {
281 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
282 $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix;
283 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
284 $wgCookiePrefix = $wgSharedDB;
285 } elseif ( $wgDBprefix ) {
286 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
287 } else {
288 $wgCookiePrefix = $wgDBname;
289 }
290 }
291 $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
292
293 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
294
295 if ( $wgMetaNamespace === false ) {
296 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
297 }
298
299 // Default value is either the suhosin limit or -1 for unlimited
300 if ( $wgResourceLoaderMaxQueryLength === false ) {
301 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
302 $wgResourceLoaderMaxQueryLength = $maxValueLength > 0 ? $maxValueLength : -1;
303 }
304
305 /**
306 * Definitions of the NS_ constants are in Defines.php
307 * @private
308 */
309 $wgCanonicalNamespaceNames = array(
310 NS_MEDIA => 'Media',
311 NS_SPECIAL => 'Special',
312 NS_TALK => 'Talk',
313 NS_USER => 'User',
314 NS_USER_TALK => 'User_talk',
315 NS_PROJECT => 'Project',
316 NS_PROJECT_TALK => 'Project_talk',
317 NS_FILE => 'File',
318 NS_FILE_TALK => 'File_talk',
319 NS_MEDIAWIKI => 'MediaWiki',
320 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
321 NS_TEMPLATE => 'Template',
322 NS_TEMPLATE_TALK => 'Template_talk',
323 NS_HELP => 'Help',
324 NS_HELP_TALK => 'Help_talk',
325 NS_CATEGORY => 'Category',
326 NS_CATEGORY_TALK => 'Category_talk',
327 );
328
329 /// @todo UGLY UGLY
330 if ( is_array( $wgExtraNamespaces ) ) {
331 $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
332 }
333
334 # These are now the same, always
335 # To determine the user language, use $wgLang->getCode()
336 $wgContLanguageCode = $wgLanguageCode;
337
338 # Easy to forget to falsify $wgShowIPinHeader for static caches.
339 # If file cache or squid cache is on, just disable this (DWIMD).
340 # Do the same for $wgDebugToolbar.
341 if ( $wgUseFileCache || $wgUseSquid ) {
342 $wgShowIPinHeader = false;
343 $wgDebugToolbar = false;
344 }
345
346 # Doesn't make sense to have if disabled.
347 if ( !$wgEnotifMinorEdits ) {
348 $wgHiddenPrefs[] = 'enotifminoredits';
349 }
350
351 # $wgDisabledActions is deprecated as of 1.18
352 foreach ( $wgDisabledActions as $action ) {
353 $wgActions[$action] = false;
354 }
355
356 # We always output HTML5 since 1.22, overriding these is no longer supported
357 # we set them here for extensions that depend on its value.
358 $wgHtml5 = true;
359 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
360 $wgJsMimeType = 'text/javascript';
361
362 if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
363 # see http://www.w3.org/TR/rdfa-in-html/#document-conformance
364 if ( $wgMimeType == 'application/xhtml+xml' ) {
365 $wgHtml5Version = 'XHTML+RDFa 1.0';
366 } else {
367 $wgHtml5Version = 'HTML+RDFa 1.0';
368 }
369 }
370
371 # Blacklisted file extensions shouldn't appear on the "allowed" list
372 $wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
373
374 if ( $wgArticleCountMethod === null ) {
375 $wgArticleCountMethod = $wgUseCommaCount ? 'comma' : 'link';
376 }
377
378 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
379 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
380 }
381
382 if ( $wgNewUserLog ) {
383 # Add a new log type
384 $wgLogTypes[] = 'newusers';
385 $wgLogNames['newusers'] = 'newuserlogpage';
386 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
387 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
388 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
389 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
390 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
391 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
392 }
393
394 if ( $wgCookieSecure === 'detect' ) {
395 $wgCookieSecure = ( WebRequest::detectProtocol() === 'https' );
396 }
397
398 if ( $wgRC2UDPAddress ) {
399 $wgRCFeeds['default'] = array(
400 'formatter' => 'IRCColourfulRCFeedFormatter',
401 'uri' => "udp://$wgRC2UDPAddress:$wgRC2UDPPort/$wgRC2UDPPrefix",
402 'add_interwiki_prefix' => &$wgRC2UDPInterwikiPrefix,
403 'omit_bots' => &$wgRC2UDPOmitBots,
404 );
405 }
406
407 wfProfileOut( $fname . '-defaults' );
408
409 // Disable MWDebug for command line mode, this prevents MWDebug from eating up
410 // all the memory from logging SQL queries on maintenance scripts
411 global $wgCommandLineMode;
412 if ( $wgDebugToolbar && !$wgCommandLineMode ) {
413 wfProfileIn( $fname . '-debugtoolbar' );
414 MWDebug::init();
415 wfProfileOut( $fname . '-debugtoolbar' );
416 }
417
418 if ( !class_exists( 'AutoLoader' ) ) {
419 require_once "$IP/includes/AutoLoader.php";
420 }
421
422 wfProfileIn( $fname . '-exception' );
423 MWExceptionHandler::installHandler();
424 wfProfileOut( $fname . '-exception' );
425
426 wfProfileIn( $fname . '-includes' );
427 require_once "$IP/includes/normal/UtfNormalUtil.php";
428 require_once "$IP/includes/GlobalFunctions.php";
429 require_once "$IP/includes/normal/UtfNormalDefines.php";
430 wfProfileOut( $fname . '-includes' );
431
432 wfProfileIn( $fname . '-defaults2' );
433 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
434 $wgSecureLogin = false;
435 wfWarn( 'Secure login was enabled on a server that only supports HTTP or HTTPS. Disabling secure login.' );
436 }
437
438 # Now that GlobalFunctions is loaded, set defaults that depend
439 # on it.
440 if ( $wgTmpDirectory === false ) {
441 wfProfileIn( $fname . '-tempDir' );
442 $wgTmpDirectory = wfTempDir();
443 wfProfileOut( $fname . '-tempDir' );
444 }
445
446 if ( $wgCanonicalServer === false ) {
447 $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
448 }
449
450 // $wgHTCPMulticastRouting got renamed to $wgHTCPRouting in MediaWiki 1.22
451 // ensure back compatibility.
452 if ( !$wgHTCPRouting && $wgHTCPMulticastRouting ) {
453 $wgHTCPRouting = $wgHTCPMulticastRouting;
454 }
455
456 // Initialize $wgHTCPRouting from backwards-compatible settings that
457 // comes from pre 1.20 version.
458 if ( !$wgHTCPRouting && $wgHTCPMulticastAddress ) {
459 $wgHTCPRouting = array(
460 '' => array(
461 'host' => $wgHTCPMulticastAddress,
462 'port' => $wgHTCPPort,
463 )
464 );
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 wfDebug( 'CACHES: ' . get_class( $wgMemc ) . '[main] ' .
519 get_class( $messageMemc ) . '[message] ' .
520 get_class( $parserMemc ) . "[parser]\n" );
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 StubObject( 'wgAuth', '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 );