Page MenuHomePhabricator

Investigation: Category link parameters to support aliases
Closed, ResolvedPublic


We might want to add a parameter when defining categories on an article page like [[Kategorie:Physiker|display=Physikerin]]. The given value should then be the string displayed on the category list of that article.

  • Check how and where that could be applied in the parser
  • Check if we could do that with hooks via an extension
  • Think about ways to make these "category aliases" persistent in the storage so they could be used on editing, search and for redirects

See also T2491

Event Timeline

awight added a subscriber: awight.Jul 18 2019, 8:16 AM

One shortcoming of this solution vs. the related "category redirect" idea investigated in T227877 is that the display name is not checked for correctness. In other words, with redirected categories the editor could write [[Kategorie:Physikerin]] and would immediately get feedback whether the category exists or is misspelled.

awight updated the task description. (Show Details)Jul 19 2019, 11:07 AM

There's *almost* a nice way to pass a hook any options encoded in what is currently the category's sort key, similar to what we allow for files. But it's not quite wired up like this. Image options on the other hand have many extension points, see ParserMakeImageParams.

I think we would have to make some core changes to expose Category tag parsing to extensions, and add a similar expectation that users are able to set options.

If we change core, it will probably be in Parser#replaceInternalLinks2, parallel to where we call makeImage on the options attached to File tags. The intermediate representations are currently a bad fit for adding extra information about the category link. I think it would be easy to change the display of the link, but tracking e.g. the alias and the original, and making database updates for each seems difficult. These updates should happen outside of the parser, so the info needs to propagate further, to somewhere like LinksUpdater.

We can change core to allow for parameters in category tags, but implement the actual parameters in an extension.

As mentioned above, this hook doesn't seem like a good place to make transactional database queries to insert category aliases. Hopefully, we can stash some of this information and retrieve it in a deferred job like LinksUpdater, but I don't have ideas about how that could be done.

WMDE-Fisch renamed this task from Investigation: Check how a category alias system could be implemented for gendered categories to Investigation: Category parameters to support aliases.Jul 23 2019, 10:08 AM
WMDE-Fisch renamed this task from Investigation: Category parameters to support aliases to Investigation: Category link parameters to support aliases.Jul 23 2019, 10:11 AM
Lea_WMDE closed this task as Resolved.Jul 24 2019, 12:42 PM
Lea_WMDE claimed this task.
Lea_WMDE added a subscriber: Lea_WMDE.

Most likely, having an alias is not the most promising solution, since we would most likely have to touch all places in code where categories are used at all, making them usable with a new structure. This is a mega project in itself