* dan nessett dnessett@yahoo.com [Tue, 11 Aug 2009 09:57:28 -0700 (PDT)]:
I just tried the following two approaches. I created the file
MWInit.php
in my .../phase3 directory with the following code:
<?php function MWInit() { $IP = strval( getenv('MW_INSTALL_PATH') ) !== '' ? getenv('MW_INSTALL_PATH') : realpath( dirname( __FILE__ )); return $IP; } I then modified include_path in php.ini to include my ../phase3 directory. In phase3/maintenance I created the file GetIP.php with the following code: <?php require_once('MWInit.php'); $IP = MWInit(); ?>
This worked. $IP was set to the correct value.
However, Dmitriy Sintsov makes the excellent point that not everyone
can
change php.ini. So, I then put MWInit.php into the PEAR directory and modified it as follows:
<?php
function MWInit() {
$IP = "/Volumes/Macintosh 2nd HD/DataBucket/Wiki Work/Code
Development/LatestTrunkVersion/phase3";
return $IP; }
I removed my ../phase3 directory from include_path in php.ini and once again ran GetIP.php. $IP was returned successfully.
The question may arise, how do you get the value of the MW root into MWInit.php in the first place? This can occur on MW installation. Of course, there may be a problem getting MWInit.php into the PEAR directory, but I assume that is an easier task than modifying php.ini. However, if even this is a problem, then we can do what Dmitry
suggests,
set an environmental variable to the MW root path.
As I pointed out before, there may be better ways of automatically getting the value of $IP. However, I don't think it requires any
manual
effort.
MW_INSTALL_PATH should already work and it's very useful for command line scripts. For some extensions, like Semantic MediaWiki, which has it's own complex maintenance scripts, it's very much recommended to set this variable (so the extension can easily figure out the path). It allows to run from any directory, no need to cd to maintenance dir. The one problem I've had once (a rare case), when I was looking at then new MW 1.15 and yet wasn't ready to upgrade the whole farm from v1.14 (a long task), I've installed MW 1.15 to separate directory instead of upgrading MW 1.14 and the new one (1.15) didn't work because BOTH of MediaWikis were reading the same MW_INSTALL_PATH, which pointed out to the farm dir ! Though that's a rare case. Dmitriy