- $tags = self::getChangeTagInfo( $context );
- foreach ( $tags as &$tagInfo ) {
- $tagInfo['labelMsg'] = $tagInfo['labelMsg']->plain();
- if ( $tagInfo['descriptionMsg'] ) {
- $tagInfo['descriptionMsg'] = $tagInfo['descriptionMsg']->plain();
+ $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+ return $cache->getWithSetCallback(
+ $cache->makeKey( 'ChangesListSpecialPage-changeTagListSummary', $context->getLanguage() ),
+ WANObjectCache::TTL_DAY,
+ function ( $oldValue, &$ttl, array &$setOpts ) use ( $context ) {
+ $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
+ $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
+
+ $tagStats = ChangeTags::tagUsageStatistics();
+ $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
+
+ $result = [];
+ foreach ( $tagHitCounts as $tagName => $hits ) {
+ if (
+ (
+ // Only get active tags
+ isset( $explicitlyDefinedTags[ $tagName ] ) ||
+ isset( $softwareActivatedTags[ $tagName ] )
+ ) &&
+ // Only get tags with more than 0 hits
+ $hits > 0
+ ) {
+ $labelMsg = ChangeTags::tagShortDescriptionMessage( $tagName, $context );
+ if ( $labelMsg === false ) {
+ // Tag is hidden, skip it
+ continue;
+ }
+ $descriptionMsg = ChangeTags::tagLongDescriptionMessage( $tagName, $context );
+ $result[] = [
+ 'name' => $tagName,
+ 'labelMsg' => $labelMsg,
+ 'label' => $labelMsg->plain(),
+ 'descriptionMsg' => $descriptionMsg,
+ 'description' => $descriptionMsg ? $descriptionMsg->plain() : '',
+ 'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
+ 'hits' => $hits,
+ ];
+ }
+ }
+ return $result;