I would like to fix the behavior of the Graphviz extension regarding the handling of instant commons files as asked at https://www.mediawiki.org/wiki/Extension_talk:GraphViz#instant_commons.
I found the following relevant source code lines in Version 2.1.0:
GraphViz_body.php lines 797 ff:
$imageFile = UploadLocalFile::getUploadedFile( $imageName );
if ( $imageFile ) {
$result = 'image="' . $imageFile->getLocalRefPath() . '"';
wfDebug( __METHOD__ . ": replacing: $imageName with: $result\n" );
return $result;
} else {
wfDebug( __METHOD__ . ": removing invalid imageName: $imageName\n" );
return 'image=""';
}
and UploadLocalFile.php lines 202 ff:
/**
* Check if the given file has been uploaded to the wiki.
*
* @param[in] string $filename is the name of the file to check.
* @return File: file, or null on failure
*/
static function getUploadedFile( $fileName ) {
$upload = new UploadFromLocalFile;
$upload->initializePathInfo( $fileName, "", 0, false );
$title = $upload->getTitle();
$file = wfFindFile( $title );
return $file;
}
the issue seems to be that wfFindFile will not find the File in the instant commons case.
I donot understand how InstantCommons works in detail. It seems there is no local cached copy available of an instant commons file and therefore the above call fails. So what would be the best approach to achieve that the above code will return the proper image URL in the instant commons case?