Page MenuHomePhabricator

Preloading with Special:MyLanguage broken when the UI language is same as the content language
Closed, ResolvedPublic5 Estimated Story PointsBUG REPORT

Description

Steps to reproduce

  1. Open https://meta.wikimedia.org/wiki/IP_Editing:_Privacy_Enhancement_and_Abuse_Mitigation/IP_Info_feature/Feedback?action=edit&section=new&preload=Special%3AMyLanguage%2FTemplate%3AIPInfoFeedback&uselang=de
  2. Notice that the questions are preloaded without any Translate markup.
  3. Open https://meta.wikimedia.org/wiki/IP_Editing:_Privacy_Enhancement_and_Abuse_Mitigation/IP_Info_feature/Feedback?action=edit&section=new&preload=Special%3AMyLanguage%2FTemplate%3AIPInfoFeedback&uselang=en

Actual result

  1. Notice that the preload is full of Translate markup.

Expected result

  1. Notice that the questions are preloaded without any Translate markup.

Analysis

Special:MyLanguage redirects to the page without language suffix if the UI language is same as the content language (e.g. Special:MyLanguage/Template:IPInfoFeedback?uselang=de redirects to Template:IPInfoFeedback/de, but Special:MyLanguage/Template:IPInfoFeedback?uselang=en redirects to Template:IPInfoFeedback, not Template:IPInfoFeedback/en). This results in nicer URLs, but breaks transclusion.

Possible solutions

  • Add a new (optional, by default false) parameter to SpecialMyLanguage::getRedirect to always request a language subpage (e.g. $forTranslation). Whenever $base would be returned, return $base->getSubpage($contLang->getCode()) instead (but only if $forTranslation is true). Set this parameter in the call from EditPage::getPreloadedContent, as if the user specifically set Special:MyLanguage in the preload title, we can assume that the target is a translatable page. (If it isn’t, the proposed logic could result in an empty preload content even if the base page is not empty.)
  • Leverage translation-aware transclusion introduced in T47096: after potentially resolving the Special:MyLanguage redirect, run the necessary hooks to get the subpage title if, and only if, translation-aware transclusion is enabled. This would make the preload and the normal translcusion work more similarly, which could help avoiding confusion. It would also never result in blank preloads: if the target page is not translatable, it won’t have translation-aware transclusion enabled.

Further information

The EditPage code in question was introduced in 94ab2e6ac45337191918a2a65e0880a2846b5859 (T299544).

Event Timeline

@Niharika added 1 project(s): IP Info.

I intentionally did not add this tag—this bug is in MediaWiki core, not in the IP Info extension. Adding the tag suggests that changes may be needed in the extension as part of this task, but the changes in the extension are tracked in T305451 instead.

AGueyte set the point value for this task to 5.Jun 13 2022, 3:22 PM

Change 805422 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/core@master] SpecialMyLanguage: Add parameter for returning translateable page

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

Change 805802 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/VisualEditor@master] Ensure base translation page is not proloaded in editor

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

Change 805422 merged by jenkins-bot:

[mediawiki/core@master] SpecialMyLanguage: Add method for finding a Title for transclusion

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

Change 805802 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] Avoid preloading base translation page in editor

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

dom_walden subscribed.

The bug is no longer reproducible on beta in wikieditor or visualeditor.

Otherwise, I tested that the correct translations are loaded and we fallback where there is no translation.

Locally, I tested that it worked when setting the site language to be something other than English.

The only thing I noticed is that if the site language is French (say) and the transcluded template is not translated into English, if you preload it with an English UI language (or a language which falls back to English) you will see the <translate> tags. But this can be fixed by adding an English translation.

I briefly checked that just going to Special:MyLanguage/Template:<page> normally redirects you to the appropriate page (i.e. for English to Template:<page> and for another <lang> to Template:<page>/<lang>).

I tested that regular transclusion of templates works as it did before (although I don't think we touched that functionality).

Test environment: