Page MenuHomePhabricator

Image thumbs on Persian Wikipedia broken when you click on them (due to Gadget-Direct-link-to-Commons.js attaching uselang parameter)
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue:

What happens?:

  • An error occurs: در هنگام بارگذاری این تصویر، خطایی رخ داد ("An error occurred when uploading this image")

What should have happened instead?:
The image box with relevant info and a link to commons should have been shown instead—this happens only on fawiki and for images that are uploaded in commons.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):
Android 13 - Chrome 117
Windows 10 - Chrome 117
How it should look like:

image.png (1×598 px, 461 KB)

How it is on fawiki:

image.png (1×599 px, 78 KB)


I didn't know which tags to use so I'm just using MinervaNeue.

Event Timeline

Looks to fail around here, so tagging Thumbor

normalized_message
TransformationalImageHandler::doTransform: creating 800x525 thumbnail at mwstore://shared-multiwrite/local-thumb/0/0b/Cat_poster_1.jpg/800px-Cat_poster_1.jpg using scaler im

For https://fa.m.wikipedia.org/wiki/%DA%AF%D8%B1%D8%A8%D9%87#/media/File:Cat_poster_1.jpg?uselang=fa, ?uselang=fa is appended to the fragment of the URL, not the query string. MediaViewer then makes an imageinfo API query for File:Cat_poster_1.jpg?uselang=fa, which does not exist.

?uselang=fa is being added by https://fa.wikipedia.org/wiki/%D9%85%D8%AF%DB%8C%D8%A7%D9%88%DB%8C%DA%A9%DB%8C:Gadget-Direct-link-to-Commons.js . If I had to guess, this is a side effect of T127268: Dismantle ResourceLoader's "targets" system/T328610: Default gadgets to run on mobile as the script still works on desktop. The script is an old copy of https://www.mediawiki.org/wiki/Snippets/Direct_imagelinks_to_Commons with various fixes and changes piled on top. The current version of the script seems to have no effect on Minerva, but also does not include the uselang feature.

The simplest option is probably to only load this script on non-Minerva skins using |skins=vector,vector-2022,monobook,timeless,modern,cologneblue] in the gadget definition.

Aklapper renamed this task from Image thumbs on Persian Wikipedia are broken when you click on them to Image thumbs on Persian Wikipedia broken when you click on them (due to Gadget-Direct-link-to-Commons.js attaching uselang parameter).Oct 16 2023, 9:13 AM

The simplest option is probably to only load this script on non-Minerva skins using |skins=vector,vector-2022,monobook,timeless,modern,cologneblue] in the gadget definition.

Seems like that would be prone to break in future and i'd be worried about it copied to over projects. Seems straightforward enough to fix the gadget so I'll do that later and update here.

After patching the code and on closer inspection this seems to be a bug in MobileFrontend.

When I run the following code, I see that the Thumbnail objects contain the query string in the file path.

mw.mobileFrontend.require('mobile.startup').currentPageHTMLParser().getThumbnails()

I suspect this code is at fault here.
https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/0652ba81c60c25d7714b7e965c251cd415caedda/src/mobile.startup/PageHTMLParser.js#L173C2-L173C2

Patch very much welcome.