Page MenuHomePhabricator

Some articles with gallery fail to start for translation
Closed, ResolvedPublicBUG REPORT

Description

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

  • Visit Special:ContentTranslation in Serbian Wikipedia
  • Change source wiki/language to Croatian (hr)
  • Choose the article Kapuljača to translate

What happens?:
Content translation opens and loads, with the error:

image.png (1×1 px, 129 KB)

What should have happened instead?:
It shouldn't throw any error, but to allow me to translate.

Software version (skip for WMF-hosted wikis like Wikipedia):
Serbian Wikipedia, which is having 1.42.0-wmf.4 (de18cff) at this moment, ContentTranslation - 17376f4

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

  • Microsoft Edge 119.0.2151.58 64-bit
  • Windows 11

I've had no luck translating that article for a couple of months now, I'm getting superstitious.
It was just loading forever earlier when I was trying, now it's throwing an error at least.

The browser console is showing me only: mw.cx.init.Translation.js:234 [CX] Translation initialization failed.
(you can actually see it in the screenshot)

EDIT: Error from local testing:

TypeError: img is null
    toDataElement ve.dm.MWGalleryImageNode.js:81
    createDataElements ve.dm.Converter.js:548

Event Timeline

This issue is related to some image gallery node that exists inside the source article. Apparently, there are some issues with image galleries. This isn't in the Content Translation side, so we'll have to investigate if the issue lies in the cxserver or the visual editor.

Oh, it's probably because of <gallery></gallery> tags, I had trouble with it in section translation while trying to translate a section from enwiki to srwiki. So, the issue is with that specific tag.

Oh, it's probably because of <gallery></gallery> tags, I had trouble with it in section translation while trying to translate a section from enwiki to srwiki. So, the issue is with that specific tag.

Oh, that part about section translation is actually T275495: Support for galleries in Section translation.

Change 974943 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/services/cxserver@master] MWGallery: Support the new HTML format as per MW Dom Spec 2.7.0

https://gerrit.wikimedia.org/r/974943

santhosh renamed this task from Cx-init-critical-error in Serbian Wikipedia to Gallery adaptation fails with updated MW Dom Spec.Nov 16 2023, 10:21 AM
santhosh claimed this task.
santhosh triaged this task as Medium priority.
santhosh updated the task description. (Show Details)
Nikerabbit changed the task status from Open to In Progress.Nov 23 2023, 8:47 AM
ngkountas renamed this task from Gallery adaptation fails with updated MW Dom Spec to Some articles with gallery fail to start for translation .Nov 24 2023, 2:22 PM
ngkountas claimed this task.
ngkountas updated the task description. (Show Details)
ngkountas added a subscriber: santhosh.

It turns out that this issue is caused because the image elements (<img>) inside galleries are expected to have the .mw-file-element class, inside the toDataElement of ve.dm.MWGalleryImageNode class. This class is part of VisualEditor extension. This expectation exists because since MW Dom Spec 2.7.1 these image elements should have this class (T314097).

Now, the cxserver currently uses under the hood the RESTBase API to fetch the page content which uses MW Dom Spec 2.6.0 (request: https://hr.wikipedia.org/api/rest_v1/page/html/Kapulja%C4%8Da). The content from these responses do not include the expected .mw-file-element classes, leading to an unhandled JS error.

On the bright side, once this patch is merged, the cxserver will start using the MediaWiki REST API instead, which uses MW Dom Spec 2.8.0 (request: https://hr.wikipedia.org/w/rest.php/v1/page/Kapulja%C4%8Da/html) and the issue will be resolved.

Change 976152 had a related patch set uploaded (by Nik Gkountas; author: Santhosh):

[mediawiki/services/cxserver@master] Use MediaWiki REST API endpoint instead of RESTbase

https://gerrit.wikimedia.org/r/976152

It turns out that this issue is caused because the image elements (<img>) inside galleries are expected to have the .mw-file-element class, inside the toDataElement of ve.dm.MWGalleryImageNode class. This class is part of VisualEditor extension. This expectation exists because since MW Dom Spec 2.7.1 these image elements should have this class (T314097).

Now, the cxserver currently uses under the hood the RESTBase API to fetch the page content which uses MW Dom Spec 2.6.0 (request: https://hr.wikipedia.org/api/rest_v1/page/html/Kapulja%C4%8Da). The content from these responses do not include the expected .mw-file-element classes, leading to an unhandled JS error.

On the bright side, once this patch is merged, the cxserver will start using the MediaWiki REST API instead, which uses MW Dom Spec 2.8.0 (request: https://hr.wikipedia.org/w/rest.php/v1/page/Kapulja%C4%8Da/html) and the issue will be resolved.

🎆🎆🎆

Change 976152 merged by jenkins-bot:

[mediawiki/services/cxserver@master] Use MediaWiki REST API endpoint instead of RESTbase

https://gerrit.wikimedia.org/r/976152

Change 977983 had a related patch set uploaded (by KartikMistry; author: KartikMistry):

[operations/deployment-charts@master] Update cxserver to 2023-11-28-064518-production

https://gerrit.wikimedia.org/r/977983

The above fix has now been deployed and the issue is fixed on production.

Change 977983 merged by jenkins-bot:

[operations/deployment-charts@master] Update cxserver to 2023-12-04-083437-production

https://gerrit.wikimedia.org/r/977983

Mentioned in SAL (#wikimedia-operations) [2024-02-15T05:43:22Z] <kart_> Update cxserver to 2023-12-04-083437-production (T344982, T338432, T351138)