r78308 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78307‎ | r78308 | r78309 >
Date:15:30, 13 December 2010
Author:demon
Status:ok (Comments)
Tags:
Comment:
Fix for r75858: Move $IP detection further up so it can be used in child constructors
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/Maintenance.php
@@ -102,10 +102,16 @@
103103 protected static $mCoreScripts = null;
104104
105105 /**
106 - * Default constructor. Children should call this if implementing
 106+ * Default constructor. Children should call this *first* if implementing
107107 * their own constructors
108108 */
109109 public function __construct() {
 110+ // Setup $IP, using MW_INSTALL_PATH if it exists
 111+ global $IP;
 112+ $IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== ''
 113+ ? getenv( 'MW_INSTALL_PATH' )
 114+ : realpath( dirname( __FILE__ ) . '/..' );
 115+
110116 $this->addDefaultParams();
111117 register_shutdown_function( array( $this, 'outputChanneled' ), false );
112118 }
@@ -415,7 +421,7 @@
416422 * Do some sanity checking and basic setup
417423 */
418424 public function setup() {
419 - global $IP, $wgCommandLineMode, $wgRequestTime;
 425+ global $wgCommandLineMode, $wgRequestTime;
420426
421427 # Abort if called from a web server
422428 if ( isset( $_SERVER ) && isset( $_SERVER['REQUEST_METHOD'] ) ) {
@@ -459,11 +465,6 @@
460466 # Define us as being in MediaWiki
461467 define( 'MEDIAWIKI', true );
462468
463 - # Setup $IP, using MW_INSTALL_PATH if it exists
464 - $IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== ''
465 - ? getenv( 'MW_INSTALL_PATH' )
466 - : realpath( dirname( __FILE__ ) . '/..' );
467 -
468469 $wgCommandLineMode = true;
469470 # Turn off output buffering if it's on
470471 @ob_end_flush();

Follow-up revisions

RevisionCommit summaryAuthorDate
r793731.17: MFT r78308, r78622, r79089, r79185, r79199, r79213, r79214, r79253catrope21:09, 31 December 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75858Followup r70207, make path for LocalSettings.php configurabledemon17:11, 2 November 2010

Comments

#Comment by Catrope (talk | contribs)   16:18, 31 December 2010
+			: realpath( dirname( __FILE__ ) . '/..' );

Any reason not to use dirname( dirname( __FILE__ ) ) here?

#Comment by Platonides (talk | contribs)   16:19, 31 December 2010

Looks symlink related.

#Comment by 😂 (talk | contribs)   21:47, 31 December 2010

This was copy+pasted from old maintenance stuff. Can probably dig back there for the reason :)

#Comment by Platonides (talk | contribs)   22:16, 21 January 2011

It has been there since r4083, apparently with no reason to prefer it over a double dirname(), although at that time __FILE__ wouldn't be guaranteed yet to deliver a good path, needing the realpath() anyway.

Status & tagging log