Steps to reproduce
- Open https://meta.wikimedia.org/wiki/IP_Editing:_Privacy_Enhancement_and_Abuse_Mitigation/IP_Info_feature/Feedback?action=edit§ion=new&preload=Special%3AMyLanguage%2FTemplate%3AIPInfoFeedback&uselang=de
- Notice that the questions are preloaded without any Translate markup.
- Open https://meta.wikimedia.org/wiki/IP_Editing:_Privacy_Enhancement_and_Abuse_Mitigation/IP_Info_feature/Feedback?action=edit§ion=new&preload=Special%3AMyLanguage%2FTemplate%3AIPInfoFeedback&uselang=en
Actual result
- Notice that the preload is full of Translate markup.
Expected result
- 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).