Page MenuHomePhabricator

Template used in information->description causes wrong image description to be returned from API
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

The caption is 'This file illustrates a cultural heritage monument in Moldova, ID'

What should have happened instead?:

Caption should be 'Wine cellars of Mileștii Mici, Chișinău, Moldova' because {{information}} is:

{{Information
|description={{en|1=Wine cellars of Mileștii Mici, Chișinău, Moldova}}
{{Monument ocrotit de stat|MD-IL-Is-N-0738}}
|date=2023-11-02 20:44:18

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia): It's Wikimedia Commons

Other information (browser name/version, screenshots, etc.):

Tested on Firefox 132, but it's not related to browser. The caption comes from query -> pages -> iageinfo -> extmetadata -> ImageDescription returned by api.php?action=query&format=json&formatversion=2&prop=imageinfo

Other affected areas:

It also breaks correct 'Captions' metadata provided on Commons. If you have a caption, and description= field is empty, Media Viewer correctly uses the caption. But I saw files where a caption was given but 'description' was just a template on cultural heritage. Or sometimes just {{Commonist}}. With such a form of 'description', Media Viewer replaces the useful caption with a generic text about cultural heritage, or even displays blank caption.

Surprisingly, there are cases where a template is used in the description= field, but the ImageDescription extracted by the API is correct. See https://commons.wikimedia.org/wiki/File:Nikiszowiec,_courtyard_with_chimneys,_2024-08-09.jpg.

It's hard to understand why 2 files with similar wikicode inside {{information}} give drastically different results in the result of extracted ImageDescription. It would be good if there is a documentation targetted to users not familiar with MediaWiki internals of how ImageDescription extraction works: what is allowed inside description= wikicode and what should be allowed.

The bug was discussed on Wikimedia Commons: https://commons.wikimedia.org/wiki/Commons:Village_pump/Technical/Archive/2024/10#Templates_in_description_field_cause_empty_caption_in_Media_Viewer

You can find a few more 'test cases' there.

Event Timeline

Tacsipacsi added subscribers: Nux, Tacsipacsi.

CommonsMetadata (and not SDC!) looks for the description class, and if it finds multiple instances, it apparently chooses the last one. The Polish image works because @Nux fixed it for T373979 (which is probably a duplicate of the current task).

Yeah, you would have to edit this: https://commons.wikimedia.org/wiki/Template:Monument_ocrotit_de_stat/layout

Remove {{lang...}} template, and maybe add dir/lang attributes to the main <div> tag.