Page MenuHomePhabricator

Mark Skin::buildContentNavigationUrls as @internal
Closed, ResolvedPublicBUG REPORT

Description

In preparation for a future refactor I'd like to make Skin::buildContentNavigationUrls @internal, with the eventual plan to deprecate and replace the method.

Mirage, Tempo, WMAU, Nimbus, Citizen, Minerva

TODO

  • Understand what limitations Skin::getTemplateData has that leads skins to use this method.
  • Provide alternatives (where needed) for all the associated skins via hooks/updates to template data.
  • Mark Skin::buildContentNavigationUrls as an @internal method making it clear the method shouldn't be extended or used as precursor to making it private
  • Make the method as deprecated (We can do this by making buildContentNavigationUrls call a private method buildContentNavigationUrlsInternal and send deprecation warnings when buildContentNavigationUrls is called)
  • submit patch for Tempo https://gerrit.wikimedia.org/r/c/mediawiki/skins/Tempo/+/761405/1
  • submit patch for Citizen https://github.com/StarCitizenTools/mediawiki-skins-Citizen/issues/422

Event Timeline

I've checked for MediaWiki-skins-Mirage. Mirage uses buildContentNavigationUrls in one place, twice: Once to determine if it needs to provide its own notification bell, and once to create an edit button dropdown for the views and actions portlet. The first issue can be addressed with an alternate approach. It would be helpful to have the html-items property of portlets be null when there are none instead of an empty string so that the conditional logic in mustache templates can be used, but I've worked around that in Mirage itself for now. The second issue is more difficult to address as the portlets provided to mustache are already turned into HTML, preventing modification.

I'm sure I'm able to come up with a convoluted approach for that given time, but right now I can't think of anything that would solve the dependency on buildContentNavigationUrls without re-engineering half of MediaWiki, Mirage, or both.

For the first usage, I've uploaded https://gerrit.wikimedia.org/r/c/mediawiki/skins/Mirage/+/757728.

Change 757841 had a related patch set uploaded (by Mainframe98; author: Mainframe98):

[mediawiki/core@master] Skins: Supply is-empty for portlets

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

  • Minerva appears to be using buildContentNavigationUrls to get at the raw data to inform the building of its own menu items. I'm pretty sure it could do this via hooks but this would be a non-trivial (but achievable) refactor to get the same desired result.
  • @alistair3149 from what I can see Citizen skin is using similar code to Vector and using it inside Skin::buildPageTools to create data for the template. I don't think it's transforming the data in any way. Could the existing data-portlets be used to the same effect or am I missing something?
  • WMAU skin seems to be creating its own menu from existing menu items. I'm pretty sure the same result can be achieved using SkinTemplateNavigationUniversal to register a custom menu. See CologneBlue for reference (https://github.com/wikimedia/mediawiki-skins-CologneBlue/blob/master/includes/CologneBlueHooks.php#L231) @Samwilson could you take a look and see if that's correct? Happy to help guide you if there's any problems.
  • Tempo is a PHP SkinTemplate skin. It can use $tpl->set( 'content_navigation' ) to unset items.
  • Nimbus is doing something pretty hacky using ReflectMethod to call buildContentActionUrls. It should just be using $tpl->get( 'content_actions' ) so also easy to fix.

Change 757841 merged by jenkins-bot:

[mediawiki/core@master] Skins: Supply is-empty for portlets

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

Change 759501 had a related patch set uploaded (by Mainframe98; author: Mainframe98):

[mediawiki/skins/Mirage@master] Create a separate portal for the edit button and its dropdown

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

https://gerrit.wikimedia.org/r/759501 fixes the second usage of Skin::buildContentNavigationUrls, the note about Minerva in T300284#7660986 gave me the idea to use a custom portlet through the SkinTemplateNavigation::Universal hook, but it feels like a bit of a hack.

Before I merge that change, I'd like to know if you, @Jdlrobson, think this might complicate matters in the future when overhauling buildContentNavigationUrls.

Change 759513 had a related patch set uploaded (by Mainframe98; author: Mainframe98):

[mediawiki/skins/Nimbus@master] Don't use reflection to access content_actions

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

Change 759513 merged by jenkins-bot:

[mediawiki/skins/Nimbus@master] Don't use reflection to access content_actions

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

Change 759679 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/skins/WMAU@master] Avoid buildContentNavigationUrls() and rearrange side tool drawer

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

@Jdlrobson Thanks for the ping. I've had a go at fixing this up, and I think the only remaining bit to sort out is how properly to remove the mainpage and specialpages links from the side drawer.

Change 759501 merged by jenkins-bot:

[mediawiki/skins/Mirage@master] Create a separate portal for the edit button and its dropdown

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

Thanks everyone. Getting this into the 1.38 release now seems very achieveable.

Change 759744 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/MinervaNeue@master] buildContentNavigationUrls will be made internal and private

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

Jdlrobson triaged this task as Medium priority.Feb 4 2022, 5:39 PM

Change 760669 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] Deprecate buildContentNavigationUrls

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

Change 759679 merged by jenkins-bot:

[mediawiki/skins/WMAU@master] Avoid buildContentNavigationUrls() and rearrange side tool drawer

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

Change 759744 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] buildContentNavigationUrls will be made internal and private

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

Change 760669 merged by jenkins-bot:

[mediawiki/core@master] Deprecate buildContentNavigationUrls

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

Change 761405 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Tempo@master] Use of Skin::buildContentNavigationUrls is deprecated

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

Jdlrobson updated the task description. (Show Details)

Thanks everyone for the help with this one!

Change 761405 merged by jenkins-bot:

[mediawiki/skins/Tempo@master] Use of Skin::buildContentNavigationUrls is deprecated

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