Ok, TimStarling's sollution is to use an environment variable and check for it using getenv.
So for example, this is what you would do to a extension script to make it work right: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/CheckUser/install...
I recommend that the form without the environment variable is the one currently in the maintenance script you modify when you make this kind of update. It'll be best for backwards compatibility.
~Daniel Friesen(Dantman) of: -The Gaiapedia (http://gaia.wikia.com) -Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG) -and Wiki-Tools.com (http://wiki-tools.com)
DanTMan wrote:
What would you think, if I created a runMaintenance.php script into the /maintenance folder which could be used to call maintenance scripts: I'll write this from my perspective, I run maintenance scripts inside the path that a wiki is installed into because that directory is the real location of the wiki, the actual maintenance and such directories are all symlinks to a central location: php ./maintenance/runMaintenance.php --root=$PWD ./maintenance/scriptname.php args... And similarly for extensions: php ./maintenance/runMaintenance.php --root=$PWD ./extension/ExtName/maintenance/scriptname.php args... The point is:
- The script checks for the cli sapi type, aborting if it fails.
- The script defines MEDIAWIKI_CLI.
- The script sets $IP to either a --root= param you give it (must be
specified before maintenance script name), or to a default "realpath( __FILE__ . '/.. );" which is compatible with default installations while allowing non-defaults to work.
- The script considers the first non-param argument you give it to be a
maintenance script name. And then strips out the script name and all arguments before it (considered to be arguments to the runscript).
- The script then includes the maintenance script to be run into itself.
- The maintenance script itself uses an $IP path only if MEDIAWIKI_CLI
is defined. Otherwise, for backwards compatibility but more security it uses "require_once( dirname(__FILE__) . "/commandLine.inc" );". Extension scripts would use the ../.. trick they normally use.
So basically the form goes: php [path to maintenance]runMaintenance.php [args to runscript] <maintenance script name> [args to maintenance script] And it maintains a fair bit of security while still being lenient on those with non-standard paths who don't want to duplicate things everywhere. You can even run extension maintenance scripts from their extensions folder, or symlink them to the maintenance folder and they'll still work.
~Daniel Friesen(Dantman) of: -The Gaiapedia (http://gaia.wikia.com) -Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG) -and Wiki-Tools.com (http://wiki-tools.com)
Mark Clements wrote:
"Simetrical" Simetrical+wikilist@gmail.com wrote in message news:7c2a12e20804221716xaa6f5cflf216ff28c6324015@mail.gmail.com...
On Tue, Apr 22, 2008 at 5:59 PM, Mark Clements wrote:
And, of course, it doesn't help when that's not the case, which is the situation for us. For technical reasons, all extensions are outside the MW source folder entirely.
Symlinks work perfectly in that case (as is true for my localhost, for instance, since it's running a checked-out version of mediawiki/trunk/). I agree it's not great practice, though: maybe you could try to use the current working directory? That seems even less reliable.
I imagine an 'updateExtension' script in the 'maintenance' folder that include()s the appropriate command line/site settings/etc. files then looks for a script with the appropriate name (based on the extension name which is supplied as first arg on command line - 'ExtName' in this example) in the following places.
*/extensions/ExtName/maintenance.php */ExtName/maintenance.php
Where * means anywhere in the include path. If the file exists, run it with the remaining arguments passed through, for which there should be a standardised subset that most extensions use (e.g. 'install' and 'upgrade') though extension-specific items are allowed. If no arg (or an unexpected arg) is provided then the extension file is expected to print out the details about available items (i.e. equivalent to 'help').
- Mark Clements (HappyDog)
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l