ChangeTags: Skip caching if some hooks aren't registered
authorKunal Mehta <legoktm@member.fsf.org>
Tue, 13 Sep 2016 06:32:06 +0000 (23:32 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 13 Sep 2016 07:00:37 +0000 (00:00 -0700)
There is caching around the ChangeTagsListActive and ListDefinedTags
hooks that can be skipped if no callers are registered for them.

Change-Id: I0c8fccc358f80536fff7ad0bda1cab09181bca41

includes/changetags/ChangeTags.php

index c8c5073..a6e4e78 100644 (file)
@@ -1132,6 +1132,9 @@ class ChangeTags {
         * @since 1.25
         */
        public static function listExtensionActivatedTags() {
+               if ( !Hooks::isRegistered( 'ChangeTagsListActive' ) ) {
+                       return [];
+               }
                return ObjectCache::getMainWANInstance()->getWithSetCallback(
                        wfMemcKey( 'active-tags' ),
                        WANObjectCache::TTL_MINUTE * 5,
@@ -1207,6 +1210,9 @@ class ChangeTags {
         * @since 1.25
         */
        public static function listExtensionDefinedTags() {
+               if ( !Hooks::isRegistered( 'ListDefinedTags' ) ) {
+                       return [];
+               }
                return ObjectCache::getMainWANInstance()->getWithSetCallback(
                        wfMemcKey( 'valid-tags-hook' ),
                        WANObjectCache::TTL_MINUTE * 5,