Since the ListActiveTags hook was implemented, I noticed a significant increase in loading time at Special:Tags. Extensions use this hook in addition to the ListDefinedTags hook. This means they must hit their database twice for many tags.
In order to implement T89553, we need a way for extensions to specify which tags should be 'patrollable', or for T91425, which tags are considered to indicate a 'problem'. If we used the same scheme, this means we would have to create yet another hook listing these.
This would only increase the performance issues, but in that case it would have a greater impact since the list of 'patrollable' tags must be fetched when displaying recent changes to users who can patrol (it would be cached, but still).
I think we should completely change the approach and instead use a single hook "ListDefinedTagsWithParams" that provides the tag names as keys and an array of params as values. 'active' would be one such param.
To get the list of all defined tags, we use array_keys. To check if a specific tag is defined, we use isset instead of in_array. We would need to hit the database only once and could get all the relevant data in one go. Having these keys is also going to be faster when making lists, since array_intersect and array_diff are just as inefficient as in_array. I think this will significantly increase loading time at Special:Tags and make it possible to efficiently fetch patrollable tags for display in revisions.
Updated table after comments 1, 2, 3. The active status is passed as a param and the (int) param for "importance" is replaced with a (bool) needcheck. Also added (string) source for name of the extension and (array) refs for passing additional params like abuse filter ids.
Updated again after patch set upload. 'needcheck' replaced with 'problem', 'refs' with 'msgParams'. Adds 'canDelete'.
key (tag name) | value (array of params) | result |
visualeditor | array( 'source' => 'VisualEditor', 'active' => true ) | active, not patrollable, not listed at Special:ProblemChanges |
visualeditor-needcheck | array( 'source' => 'VisualEditor', 'active' => true, 'problem' => true ) | active, patrollable, listed at Special:ProblemChanges |
possible vandalism | array( 'source' => 'AbuseFilter', 'active' => true, 'needcheck' => true, 'msgParams' => array( 12, 45) ) | active, used by abuse filters 12 and 45, patrollable, listed at Special:ProblemChanges |
OAuth CID : 457 | array() | inactive |
OAuth CID : 509 | array( 'canDelete' => true ) | inactive, can be deleted by sysops |
Hook name : ChangeTagsRegister
Available params : (bool) active, (bool) problem, (string) source, (array) msgParams, (bool) canDelete
The hooks ListDefinedTags, ChangeTagsListActive and ChangeTagCanDelete should be deprecated eventually.
ChangeTagCanCreate and ChangeTagAfterDelete are preserved.