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

Bawolff created this task.Feb 24 2020, 4:10 AM
Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptFeb 24 2020, 4:10 AM

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

srishakatux updated the task description. (Show Details)Feb 25 2020, 3:32 AM