Page MenuHomePhabricator

Rewrite DesktopArticleTarget#rebuildCategories, it doesn't need an API request
Closed, ResolvedPublic1 Estimated Story Points

Description

DesktopArticleTarget#rebuildCategories says:

	// We need to fetch this from the API because the category list is skin-
	// dependent, so the HTML output could be absolutely anything.

…and then it doesn't pass 'useskin', rendering itself pointless.

(Furthermore, it is impossible to do correctly when the article content comes from a different wiki, as it might in ContentTranslation. Querying the local API is incorrect, because the categories probably don't exist (so we'd have incorrect redlinks); querying the content API is incorrect, because that wiki might be using a different skin (and might not even have the one we want installed). This is theoretical though, ContentTranslation doesn't use this method.)

Luckily, as far as I can tell, that comment is only technically true. While skins could override this (Skin::getCategories()), none of them does. Skins that render categories differently (Minerva and Timeless) have a separate method, they don't override this one.

Given the hopelessness otherwise, and the TODO comment below, we should probably replace this API call with hardcoded generation of the default HTML that we expect. If the #catlinks element is missed, we should do nothing. We could mention this behavior on https://www.mediawiki.org/wiki/VisualEditor/Skin_requirements (it already talks about #catlinks).

In fact, we already do this in the wikitext preview code – MWSaveDialog#showPreview just generates <div class="catlinks"> and its contents. (Although that doesn't handle hidden categories right, that would have to be added.)

(Originally noticed during code review of https://gerrit.wikimedia.org/r/#/c/430906/)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Deskana triaged this task as Medium priority.May 8 2018, 6:44 PM
Deskana edited projects, added VisualEditor (Current work); removed VisualEditor.
Deskana moved this task from Incoming to In progress on the VisualEditor (Current work) board.

I don't think we can make it not need an API request. We can make it use a different API request, though. Or we can decide we don't care about hidden-categories being hidden in the rebuilt markup. (Status quo is already it missing the categories from templates / auto-added stuff like pages-with-syntax-errors.)

Change 432167 had a related patch set uploaded (by DLynch; owner: DLynch):
[mediawiki/extensions/VisualEditor@master] ArticleTarget: Change rendering of category preview

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

Change 432167 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] ArticleTarget: Change rendering of category preview

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

Vvjjkkii renamed this task from Rewrite DesktopArticleTarget#rebuildCategories, it doesn't need an API request to vfdaaaaaaa.Jul 1 2018, 1:12 AM
Vvjjkkii reopened this task as Open.
Vvjjkkii removed DLynch as the assignee of this task.
Vvjjkkii raised the priority of this task from Medium to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed the point value for this task.
Vvjjkkii edited subscribers, added: DLynch; removed: gerritbot, Aklapper.
CommunityTechBot renamed this task from vfdaaaaaaa to Rewrite DesktopArticleTarget#rebuildCategories, it doesn't need an API request.Jul 2 2018, 6:34 AM
CommunityTechBot closed this task as Resolved.
CommunityTechBot assigned this task to DLynch.
CommunityTechBot lowered the priority of this task from High to Medium.
CommunityTechBot set the point value for this task to 1.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot edited subscribers, added: gerritbot, Aklapper; removed: DLynch.