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//. A tag is considered active if its array of params is not empty.
To get the list of all defined tags, we apply array_keys. To get the list of all active tags, we apply array_filter then array_keys. To check if a specific tag is defined, we use isset, and to check if a specific tag is active, we cast the value of the tag to (bool). This is faster than using 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 and make it possible to efficiently fetch patrollable tags for display in revisions.
This also allows to pass non-boolean params. Assume a tag is patrollable if its importance is 1 or more, and displayed at Special:ProblemChanges if it is 2 or more. Example :
| //key// (tag name) | //value// (array of params) | //result//
| 'possible vandalism' | array( 'importance' => 2 ) | active, patrollable, listed at Special:ProblemChanges
| 'un-redirect' | array( 'importance' => 1 ) | active, patrollable
| 'visualeditor' | array( 'importance' => 0 ) | active
| 'cross namespace redirect' | array() | inactive
The hooks ListDefinedTags and ListActiveTags should be deprecated eventually.