Hello,
Sorry if this is a trivial PHP question, but I can't figure out why I can't make the file function work from inside a MediaWiki extension, while it works perfectly when executed independently from Mediawiki (see code at the end of the message).
Calling file("http://www.google.com") causes MediaWiki to show the following message:
Warning: file("http://www.google.com") - No such file or directory in /data/www/wikiomics/extensions/debug.php on line 4
So is it me or could it be an issue related to MediaWiki 1.5.6? Any suggestion is appreciated, this thing is driving me crazy.
Thanks!
Martin
Details:
In /etc/php.ini, I have that: ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. allow_url_fopen = On
And it seems that SpamBlacklist and nusoap which are require_once'd by my MediaWiki installation both use file($url) to read the contents of URLs, and it works well.
I insert require_once("extensions/debug.php"); somewhere in LocalSettings.php. For testing out of MW: http://wikiomics.org/extensions/debug.php For testing in MW: insert on some wiki page <debug>www.google.com</debug> (see http://wikiomics.org/wiki/Sandbox)
The code I use for "extensions/debug.php" is here (using MW 1.5.6):
<?php function debug ($input, $params) { $url = "http://$input"; $result = file($url); return $result ? "(debug - working: $url)" : "(debug - not working: $url)"; }
if ( defined( 'MEDIAWIKI' ) ) { // Registration of this extension $wgExtensionFunctions[] = "DebugExtension"; function DebugExtension() { global $wgParser; $wgParser->setHook("debug", "debug"); } } else { print (debug ('www.google.com','')); } ?>
-- Martin Jambon, PhD http://martin.jambon.free.fr
On Wed, 2 Aug 2006, I wrote:
Calling file("http://www.google.com") causes MediaWiki to show the
^^^^^^^^^ I mean PHP, not MediaWiki of course
following message:
-- Martin Jambon, PhD http://martin.jambon.free.fr
Martin Jambon wrote:
Sorry if this is a trivial PHP question, but I can't figure out why I can't make the file function work from inside a MediaWiki extension, while it works perfectly when executed independently from Mediawiki (see code at the end of the message).
MediaWiki disables allow_url_fopen by default as a precaution.
Note that current versions of PHP apparently don't actually take effect on that change at runtime.
-- brion vibber (brion @ pobox.com)
On Wed, 2 Aug 2006, Brion Vibber wrote:
Martin Jambon wrote:
Sorry if this is a trivial PHP question, but I can't figure out why I can't make the file function work from inside a MediaWiki extension, while it works perfectly when executed independently from Mediawiki (see code at the end of the message).
MediaWiki disables allow_url_fopen by default as a precaution.
$old_url_fopen = ini_set("allow_url_fopen", true); $result = file($url); ini_set("allow_url_fopen", $old_url_fopen);
works fine, thanks!
Martin
Note that current versions of PHP apparently don't actually take effect on that change at runtime.
-- brion vibber (brion @ pobox.com)
-- Martin Jambon, PhD http://martin.jambon.free.fr
mediawiki-l@lists.wikimedia.org