Page MenuHomePhabricator

Convert Linker to one or more services
Open, LowPublic


Currently, Linker is tagged with @todo turn this into a legacy interface for HtmlPageLinkRenderer and similar services.
In its current form, it consists of static methods that have to access MediaWikiServices and globals
See for some history of the static structure

Services used
* ContentLanguage
* LinkRenderer
* LinkRendererFactory
* NamespaceInfo
* PermissionManager
* RepoGroup
* RevisionStore
* SpecialPageFactory
* StatsdDataFactory
* TitleFormatter
* TitleParser
* UserOptionsLookup (via User::getDefaultOption, ::getBoolOption, etc.)
Globals used
* $wgSVGMaxSize
* $wgThumbLimits
* $wgThumbUpright
* $wgResponsiveImages
* $wgEnableUploads
* $wgUploadMissingFileUrl
* $wgUploadNavigationUrl
* $wgTitle (which is deprecated)
* $wgDisableAnonTalk
* $wgLang (which is deprecated)
* $wgShowRollbackEditCount
* $wgMiserMode


  • Uses wfWarn and wfDebug, which can be replaced with a LoggerInstance
  • Uses Hooks, which will require a HookContainer to be injected
  • Uses wfGetDB, which should be replaced with an ILoadBalancer

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

This class right now seems like a huge collection of quite random functionality, not even related to links. It generates table of content HTML, it formats comments, it makes headlines and much more. And it generates links too. This should be split into a whole bunch of services.

First part is split up the actual link URL generation code from the HTML generation code. As suggested in LinkRenderer TODO comment, it could be called LinkTargetResolver service - that will be useful in all sorts of non-HTML-generating context, like in API for example. That should be split out of Linker and LinkRenderer, as well out of Title::getLocalUrl, Title::getFullURL, etc.

Next step would be to work on the Linker itself. Given that this class heavily depends on wfMessage, it would be nice to finish up the new MessageFormatter system first T260689 Preliminary work of analyzing Linker methods and their usages, being if anything can be deprecated, classifying the methods into functionality groups can be done before that though.

daniel added a subscriber: daniel.

Putting this into the PET icebox. This doesn't mean it shouldn't be done (I'm very much in favor), it just means that it's unlikely to get on PET's roadmap in the foreseeable future.