Page MenuHomePhabricator

Backend changes for navigation tags
Closed, ResolvedPublic8 Estimated Story Points

Description

Background

This task covers the backend work needed to make navigation tags/filters (T399514) and staff-only tags/filters (T401949) possible.

The general plan is to have ApiWishEdit accept a tags parameter that must be one of the configured tags. These tags get mapped to a MediaWiki category. We then leverage the categorylinks table in our queries in order filter wishes by a tag.

Acceptance criteria

Outstanding work has been moved to T403907

This is written only for navigation tags, but please keep in mind that the "steward" and "components" tags will also be a thing, and ideally would use much of the same code written for navigation tags given they work in the same way.

API

  • SpecialWishlistIntake::onSubmit() has a comment that says "API wants pipe-separated arrays, not CSV." We'll want to do the same for $data['categories'] (not necessary after r1180815)
  • In ApiWishEdit, add a new entry to getAllowedParams() for the new tags param.
    • PARAM_ISMULTI should be true
    • Set the PARAM_TYPE to be the allowed wikitext values as fetched from configuration, like array_keys( $this->config->getWishTags() )

Value objects

  • Update the Wish value class to have knowledge of tags
    • Add a PARAM_TAGS constant, and include it in PARAMS
    • Update the constructor to accept an array of tags, in the form of the so-called wikitext values (not category titles)
    • Add the getter getTags()
    • Add tags to ::toArray(). In this case we already have the wikitext values, so no transformation is needed.
    • ::toWikitext() should already work without changes, since the property name matches the tag name.
    • Add tags to ::newFromWikitextParams() and any other factory methods

Store

  • Add Wish::PARAM_TAGS to WishStore::getWikitextFields(). This will cause it to be extracted from the wikitext, which is necessary since we don't store the tags in our own database tables.
  • In WishHookHandler::onLinksUpdateComplete(), iterate over $data['tags'] and run i.e. $linksUpdate->getParserOutput()->addCategory( $this->config->getTagFromWikitextVal( $tag ) )
  • AbstractWishlistStore::getAll() should accept a new $filters parameter that adjusts the query as requested by joining on categorylinks
    • To leave room for the future, this could take an IExpression (?)

Renderer

  • Add the new "Tags" section to the wish detail page in WishHookHandler::renderWishInternal()
    • We'll use the wikitext value as the suffix for i18n keys. So for patrollers, there should be a message communityrequests-tags-patrollers, and that has the full human name "Admins and patrollers".
    • Generate the localized category name using a new WishlistConfig::getCategoryLabelFromWikitextVal() method, similar to the other methods.

Related Objects

Event Timeline

MusikAnimal renamed this task from API and store changes for navigation tags to Backend changes for navigation tags.Aug 27 2025, 5:43 AM
MusikAnimal updated the task description. (Show Details)
MusikAnimal updated the task description. (Show Details)
MusikAnimal updated the task description. (Show Details)

Medium priority as this is for the second release. P2? Or are we zero-indexing and the second is P1? I forget :-P

Change #1182697 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CommunityRequests@master] Tags: Make schema changes in preparation of tags and dropping projects

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

MusikAnimal changed the task status from Open to In Progress.Aug 28 2025, 7:15 AM

Change #1182929 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CommunityRequests@master] tags: replace 'Projects' feature with tags

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

Change #1182697 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] Tags: Make schema changes in preparation of tags and dropping projects

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

Change #1182929 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] tags: replace 'Projects' feature with tags

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

All that's left now for this task is to implement the filters in AbstractWishlistStore::getAll(), and associated API changes (the latter is quite simple).

MusikAnimal raised the priority of this task from Medium to High.Sep 4 2025, 1:53 AM

Change #1185177 had a related patch set uploaded (by MusikAnimal; author: MusikAnimal):

[mediawiki/extensions/CommunityRequests@master] tags: add $filters to the store, and add tags param to ApiQueryWishes

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

Change #1185177 abandoned by MusikAnimal:

[mediawiki/extensions/CommunityRequests@master] tags: add $filters to the store, and add tags param to ApiQueryWishes

Reason:

unlicking

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

Change #1189889 had a related patch set uploaded (by Dmaza; author: Dmaza):

[mediawiki/extensions/CommunityRequests@master] Hide tag header if no tags are present

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

Change #1189889 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] Hide tag header if no tags are present

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