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.