[Mediawiki-l] PHP problem: file($url) not working from my MediaWiki extension

Martin Jambon martin_jambon at emailuser.net
Thu Aug 3 00:36:49 UTC 2006


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



More information about the MediaWiki-l mailing list