imagemediawikiwikiwikimedia-commons

InstantCommons not working in MediaWiki 1.19 and SELinux


I am setting my own MediaWiki website locally, and am not able to get the InstantCommons feature to work (used to directly embed files from commons.wikimedia.org).

I get no error message, the files I try to load from Commons using the following syntax:

  [[File:Cervus elaphus Luc Viatour 1.jpg|Cervus elaphus Luc Viatour 1]]

are just not loaded, and I end up with a red link on my page, referring to a non-existing file. It has been 2 days now that I am looking for a solution, but so far without any success.

I am running:

I have tried the following two configurations in my LocalSettings.php, without success:

$wgUseInstantCommons = true;

AND

$wgForeignFileRepos[] = array(
   'class'                   => 'ForeignAPIRepo',
   'name'                    => 'shared',
   'apibase'                 => 'http://commons.wikimedia.org/w/api.php',
   'fetchDescription'        => true, // Optional
   'descriptionCacheExpiry'  => 43200, // 12 hours, optional (values are seconds)
   'apiThumbCacheExpiry'     => 43200, // 12 hours, optional, but required for local thumb caching
);

Any suggestion is most welcome.


Solution

  • OK, this is not (yet) an answer, but a debugging suggestion. It looks to me like the HTTP request from your server to Commons is failing for some reason, but unfortunately ForeignAPIRepo doesn't indicate the cause of the error in any way.

    This is really a bug in MediaWiki, and should be fixed, but in the mean time, could you please try applying the following diff (or just manually adding the line marked with the + sign) to your includes/filerepo/ForeignAPIRepo.php file:

    Index: includes/filerepo/ForeignAPIRepo.php
    ===================================================================
    --- includes/filerepo/ForeignAPIRepo.php    (revision 97048)
    +++ includes/filerepo/ForeignAPIRepo.php    (working copy)
    @@ -385,6 +385,7 @@
            if ( $status->isOK() ) {
                    return $req->getContent();
            } else {
    +               wfDebug( "ForeignAPIRepo: HTTP GET failed: " . $status->getXML() );
                    return false;
            }
        }
    

    After applying it, try loading the file description page for a Commons image and look at the MediaWiki debug log. There should now be a line starting with ForeignAPIRepo: HTTP GET failed: followed by a few lines of XML error dump. That error data should hopefully indicate what's going wrong; please copy and paste it here.