r80331 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80330‎ | r80331 | r80332 >
Date:21:42, 14 January 2011
Author:ialex
Status:ok
Tags:
Comment:
Stylise Setup.php
Modified paths:
  • /trunk/phase3/includes/Setup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Setup.php
@@ -9,7 +9,7 @@
1010 * This file is not a valid entry point, perform no further processing unless
1111 * MEDIAWIKI is defined
1212 */
13 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1414 exit( 1 );
1515 }
1616
@@ -29,60 +29,62 @@
3030 }
3131
3232 // Set various default paths sensibly...
33 -if( $wgScript === false ) $wgScript = "$wgScriptPath/index$wgScriptExtension";
34 -if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect$wgScriptExtension";
35 -if( $wgLoadScript === false ) $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
 33+if ( $wgScript === false ) $wgScript = "$wgScriptPath/index$wgScriptExtension";
 34+if ( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect$wgScriptExtension";
 35+if ( $wgLoadScript === false ) $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
3636
37 -if( $wgArticlePath === false ) {
38 - if( $wgUsePathInfo ) {
 37+if ( $wgArticlePath === false ) {
 38+ if ( $wgUsePathInfo ) {
3939 $wgArticlePath = "$wgScript/$1";
4040 } else {
4141 $wgArticlePath = "$wgScript?title=$1";
4242 }
4343 }
4444
45 -if( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
46 -if( $wgLocalStylePath === false ) $wgLocalStylePath = "$wgScriptPath/skins";
47 -if( $wgStyleDirectory === false) $wgStyleDirectory = "$IP/skins";
48 -if( $wgExtensionAssetsPath === false ) $wgExtensionAssetsPath = "$wgScriptPath/extensions";
 45+if ( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
 46+if ( $wgLocalStylePath === false ) $wgLocalStylePath = "$wgScriptPath/skins";
 47+if ( $wgStyleDirectory === false ) $wgStyleDirectory = "$IP/skins";
 48+if ( $wgExtensionAssetsPath === false ) $wgExtensionAssetsPath = "$wgScriptPath/extensions";
4949
50 -if( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
 50+if ( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
5151
52 -if( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
53 -if( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
 52+if ( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
 53+if ( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
5454
55 -if( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
56 -if( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
57 -if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
 55+if ( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
 56+if ( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
 57+if ( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
5858
59 -if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
60 -if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
61 -if( $wgDeletedDirectory === false ) $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
 59+if ( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
 60+if ( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
 61+if ( $wgDeletedDirectory === false ) $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
6262
63 -if( isset( $wgFileStore['deleted']['directory'] ) ) {
 63+if ( isset( $wgFileStore['deleted']['directory'] ) ) {
6464 $wgDeletedDirectory = $wgFileStore['deleted']['directory'];
6565 }
6666
67 -if( isset($wgFooterIcons["copyright"]) &&
68 - isset($wgFooterIcons["copyright"]["copyright"]) &&
69 - $wgFooterIcons["copyright"]["copyright"] === array() ) {
 67+if ( isset( $wgFooterIcons['copyright'] ) &&
 68+ isset( $wgFooterIcons['copyright']['copyright'] ) &&
 69+ $wgFooterIcons['copyright']['copyright'] === array() )
 70+{
7071 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
71 - $wgFooterIcons["copyright"]["copyright"] = $wgCopyrightIcon;
 72+ $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
7273 } elseif ( $wgRightsIcon || $wgRightsText ) {
73 - $wgFooterIcons["copyright"]["copyright"] = array(
74 - "url" => $wgRightsUrl,
75 - "src" => $wgRightsIcon,
76 - "alt" => $wgRightsText,
 74+ $wgFooterIcons['copyright']['copyright'] = array(
 75+ 'url' => $wgRightsUrl,
 76+ 'src' => $wgRightsIcon,
 77+ 'alt' => $wgRightsText,
7778 );
7879 } else {
79 - unset($wgFooterIcons["copyright"]["copyright"]);
 80+ unset( $wgFooterIcons['copyright']['copyright'] );
8081 }
8182 }
8283
83 -if( isset($wgFooterIcons["poweredby"]) &&
84 - isset($wgFooterIcons["poweredby"]["mediawiki"]) &&
85 - $wgFooterIcons["poweredby"]["mediawiki"]["src"] === null ) {
86 - $wgFooterIcons["poweredby"]["mediawiki"]["src"] = "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
 84+if ( isset( $wgFooterIcons['poweredby'] ) &&
 85+ isset( $wgFooterIcons['poweredby']['mediawiki'] ) &&
 86+ $wgFooterIcons['poweredby']['mediawiki']['src'] === null )
 87+{
 88+ $wgFooterIcons['poweredby']['mediawiki']['src'] = "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
8789 }
8890
8991 /**
@@ -106,7 +108,7 @@
107109 * Initialise $wgLocalFileRepo from backwards-compatible settings
108110 */
109111 if ( !$wgLocalFileRepo ) {
110 - if( isset( $wgFileStore['deleted']['hash'] ) ) {
 112+ if ( isset( $wgFileStore['deleted']['hash'] ) ) {
111113 $deletedHashLevel = $wgFileStore['deleted']['hash'];
112114 } else {
113115 $deletedHashLevel = $wgHashedUploadDirectory ? 3 : 0;
@@ -143,7 +145,7 @@
144146 'dbUser' => $wgDBuser,
145147 'dbPassword' => $wgDBpassword,
146148 'dbName' => $wgSharedUploadDBname,
147 - 'dbFlags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT,
 149+ 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
148150 'tablePrefix' => $wgSharedUploadDBprefix,
149151 'hasSharedCache' => $wgCacheSharedUploads,
150152 'descBaseUrl' => $wgRepositoryBaseUrl,
@@ -163,7 +165,7 @@
164166 );
165167 }
166168 }
167 -if( $wgUseInstantCommons ) {
 169+if ( $wgUseInstantCommons ) {
168170 $wgForeignFileRepos[] = array(
169171 'class' => 'ForeignAPIRepo',
170172 'name' => 'wikimediacommons',
@@ -176,12 +178,12 @@
177179 }
178180
179181 if ( $wgRCFilterByAge ) {
180 - ## Trim down $wgRCLinkDays so that it only lists links which are valid
181 - ## as determined by $wgRCMaxAge.
182 - ## Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
 182+ # # Trim down $wgRCLinkDays so that it only lists links which are valid
 183+ # # as determined by $wgRCMaxAge.
 184+ # # Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
183185 sort( $wgRCLinkDays );
184 - for( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
185 - if( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
 186+ for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
 187+ if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
186188 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
187189 break;
188190 }
@@ -208,7 +210,7 @@
209211 $wgCookiePrefix = $wgDBname;
210212 }
211213 }
212 -$wgCookiePrefix = strtr( $wgCookiePrefix, "=,; +.\"'\\[", "__________" );
 214+$wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
213215
214216 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
215217
@@ -271,20 +273,20 @@
272274 require_once( "$IP/includes/AutoLoader.php" );
273275 }
274276
275 -wfProfileIn( $fname.'-exception' );
 277+wfProfileIn( $fname . '-exception' );
276278 require_once( "$IP/includes/Exception.php" );
277279 wfInstallExceptionHandler();
278 -wfProfileOut( $fname.'-exception' );
 280+wfProfileOut( $fname . '-exception' );
279281
280 -wfProfileIn( $fname.'-includes' );
 282+wfProfileIn( $fname . '-includes' );
281283 require_once( "$IP/includes/GlobalFunctions.php" );
282284 require_once( "$IP/includes/Hooks.php" );
283285 require_once( "$IP/includes/Namespace.php" );
284286 require_once( "$IP/includes/ProxyTools.php" );
285287 require_once( "$IP/includes/ObjectCache.php" );
286288 require_once( "$IP/includes/ImageFunctions.php" );
287 -wfProfileOut( $fname.'-includes' );
288 -wfProfileIn( $fname.'-misc1' );
 289+wfProfileOut( $fname . '-includes' );
 290+wfProfileIn( $fname . '-misc1' );
289291
290292 # Raise the memory limit if it's too low
291293 wfMemoryLimit();
@@ -339,8 +341,8 @@
340342 }
341343 }
342344
343 -wfProfileOut( $fname.'-misc1' );
344 -wfProfileIn( $fname.'-memcached' );
 345+wfProfileOut( $fname . '-misc1' );
 346+wfProfileIn( $fname . '-memcached' );
345347
346348 $wgMemc =& wfGetMainCache();
347349 $messageMemc =& wfGetMessageCacheStorage();
@@ -350,20 +352,20 @@
351353 get_class( $messageMemc ) . '[message] ' .
352354 get_class( $parserMemc ) . "[parser]\n" );
353355
354 -wfProfileOut( $fname.'-memcached' );
 356+wfProfileOut( $fname . '-memcached' );
355357
356 -## Most of the config is out, some might want to run hooks here.
 358+# # Most of the config is out, some might want to run hooks here.
357359 wfRunHooks( 'SetupAfterCache' );
358360
359 -wfProfileIn( $fname.'-session' );
 361+wfProfileIn( $fname . '-session' );
360362
361363 # If session.auto_start is there, we can't touch session name
362364 if ( !wfIniGetBool( 'session.auto_start' ) ) {
363365 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
364366 }
365367
366 -if( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
367 - if( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) {
 368+if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
 369+ if ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) ) {
368370 wfIncrStats( 'request_with_session' );
369371 wfSetupSession();
370372 $wgSessionStarted = true;
@@ -373,8 +375,8 @@
374376 }
375377 }
376378
377 -wfProfileOut( $fname.'-session' );
378 -wfProfileIn( $fname.'-globals' );
 379+wfProfileOut( $fname . '-session' );
 380+wfProfileIn( $fname . '-globals' );
379381
380382 $wgContLang = new StubContLang;
381383
@@ -388,7 +390,7 @@
389391 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
390392 array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry ) );
391393
392 -if( !is_object( $wgAuth ) ) {
 394+if ( !is_object( $wgAuth ) ) {
393395 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
394396 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
395397 }
@@ -399,8 +401,8 @@
400402
401403 $wgDeferredUpdateList = array();
402404
403 -wfProfileOut( $fname.'-globals' );
404 -wfProfileIn( $fname.'-extensions' );
 405+wfProfileOut( $fname . '-globals' );
 406+wfProfileIn( $fname . '-extensions' );
405407
406408 # Skin setup functions
407409 # Entries can be added to this variable during the inclusion
@@ -416,14 +418,14 @@
417419 foreach ( $wgExtensionFunctions as $func ) {
418420 # Allow closures in PHP 5.3+
419421 if ( is_object( $func ) && $func instanceof Closure ) {
420 - $profName = $fname.'-extensions-closure';
421 - } elseif( is_array( $func ) ) {
 422+ $profName = $fname . '-extensions-closure';
 423+ } elseif ( is_array( $func ) ) {
422424 if ( is_object( $func[0] ) )
423 - $profName = $fname.'-extensions-'.get_class( $func[0] ).'::'.$func[1];
 425+ $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
424426 else
425 - $profName = $fname.'-extensions-'.implode( '::', $func );
 427+ $profName = $fname . '-extensions-' . implode( '::', $func );
426428 } else {
427 - $profName = $fname.'-extensions-'.strval( $func );
 429+ $profName = $fname . '-extensions-' . strval( $func );
428430 }
429431
430432 wfProfileIn( $profName );
@@ -439,5 +441,5 @@
440442
441443 wfDebug( "Fully initialised\n" );
442444 $wgFullyInitialised = true;
443 -wfProfileOut( $fname.'-extensions' );
 445+wfProfileOut( $fname . '-extensions' );
444446 wfProfileOut( $fname );

Status & tagging log