r74684 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74683‎ | r74684 | r74685 >
Date:18:20, 12 October 2010
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
A note about symbolic link and dirname() / include() ...
Modified paths:
  • /trunk/phase3/extensions/README (modified) (history)

Diff [purge]

Index: trunk/phase3/extensions/README
@@ -12,3 +12,11 @@
1313
1414 You can find documentation and additional extensions on MediaWiki website:
1515 http://www.mediawiki.org/wiki/Category:Extensions
 16+
 17+
 18+Please note that under POSIX systems (Linux...), parent of a symbolic path
 19+refers to the link source, NOT to the target! If you need to include a
 20+file from mediawiki/, you will want to set and use MW_INSTALL_PATH env.
 21+
 22+ $IP = getenv( 'MW_INSTALL_PATH' ); // points to mediawiki/
 23+ require( "$IP/maintenance/Maintenance.php" ); // a MediaWiki file

Follow-up revisions

RevisionCommit summaryAuthorDate
r75693Follow up r74684 : use default path if MW_INSTALL_PATH is not present.hashar11:43, 30 October 2010

Comments

#Comment by Platonides (talk | contribs)   20:49, 12 October 2010

What problem are you trying to fix?

MW_INSTALL_PATH will usually not be set.

#Comment by Hashar (talk | contribs)   09:04, 13 October 2010

I had a trouble with the CodeReview extension [1] while running the svnImport.php script [2]. Relevant code is at the beginning:

$IP = getenv( 'MW_INSTALL_PATH' );

	if ( $IP === false ) {
	$IP = dirname( __FILE__ ) . '/../..';
	}
	require( "$IP/maintenance/Maintenance.php" ); 

Mediawiki is in /srv/mwtrunk Extensions are in /srv/mwextensions

I created a symbolic link /srv/mwtrunk/extensions/CodeReview poiting to /srv/mwextensions/CodeReview . In the above Code we have :

 __FILE__ => /srv/mwtrunk/extensions/CodeReview/svnImport.php
 dirname( __FILE__ ) => /srv/mwextensions/CodeReview/svnImport.php  (note symbolic link is expanded)
 + /../.. => /srv/ (which is put in $IP)

The require() call ends up trying to get /srv/maintenance/Maintenance.php and fails.

Setting MW_INSTALL_PATH to /srv/mwtrunk solved the issue.


[1] http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/CodeReview/ [2] http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/CodeReview/svnImport.php?revision=70826&view=markup

#Comment by P858snake (talk | contribs)   09:10, 13 October 2010

If you are having a issue with a extension, the best places to ask are on the extensions talk page, the I.R.C. channel, or on the general MediaWiki support desk, not a apparently random unrelated revision.

#Comment by P858snake (talk | contribs)   09:11, 13 October 2010

Also in Bugzilla.

#Comment by Platonides (talk | contribs)   14:58, 13 October 2010

He's not asking for support, he is explaining the rationale for adding that note (which I requested).

Reliable getting $IP from extension maintenance scripts is still an open problem. Specially since we shouldn't be duplicating complex logic code there. You can see [1] for the steps I took in Maps.

I'm happy with asking for a MW_CONFIG_PATH check, as far as it is done with a default in case it is fales (as svnImport.php does).

1- http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Maps/test/commandLine.inc?view=markup

#Comment by Hashar (talk | contribs)   17:40, 13 October 2010

Thanks for the tips Peachey88 :-)

#Comment by Hashar (talk | contribs)   06:12, 29 October 2010

@platonides can we remove the fixme tag or is there anything I should do ?

#Comment by Platonides (talk | contribs)   21:20, 29 October 2010

The README should be changed so that it handles if getenv( 'MW_INSTALL_PATH' ) returns false. The other paragraph may also benefit from a rewording (instead of "If you need (...), you will want to set..." something like "you should check the MW_INSTALL_PATH in case the extension isn't in the default location".

#Comment by Hashar (talk | contribs)   11:43, 30 October 2010

Follow up in r75693.

Status & tagging log