Page MenuHomePhabricator

Image links from #ifexist:Media:... are not being registered properly on tawiktionary
Open, Needs TriagePublic

Description

From this list post: https://lists.wikimedia.org/pipermail/wikitech-l/2020-February/093098.html

If you do something like {{#ifexist:Media:Foo.ogg}}, this should register a link both in the local imagelinks table, and the commons globalimagelinks table. This is used for cache clearing. Currently the link only seems to be added if the file exists.

Consider: https://ta.wiktionary.org/w/api.php?action=parse&text={{%23ifexist:Media:DoesNotExist.png}}{{%23ifexist:Media:Example.png}}&formatversion=2&prop=images|links

Expected behaviour: Both DoesNotExist.png and Example.png are registered as image links
Actual Behaviour: Only Example.png is registered.

I think the logic error is due to the early return:

$file = wfFindFile( $title );
if ( !$file ) { 
        return $else;
}
$parser->mOutput->addImage(
        $file->getName(), $file->getTimestamp(), $file->getSha1() );
return $file->exists() ? $then : $else;

This will exit before registering the dependency if the file does not exist as wfFindFile will return false.

Getting started steps

Event Timeline

Anyways, a suggested fix might be, in the !$file case, to add $parser->mOutput->addImage( $title->getDBKey() )

Hi , @Bawolff I have installed the extension.


What to do next ?

Hi , @Bawolff I have installed the extension.


What to do next ?

Actually I want to know how to produce this error and I don't know how to create a page.

How to produce is covered in the description ("If you do something like {{#ifexist:Media:Foo.ogg}}"); for editing see https://www.mediawiki.org/wiki/Help:Editing