Merge "SpecialTrackingCategories: Read from the extension registry"
authorKunal Mehta <legoktm@gmail.com>
Fri, 23 Jan 2015 19:09:21 +0000 (19:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 23 Jan 2015 19:09:21 +0000 (19:09 +0000)
includes/DefaultSettings.php
includes/parser/ParserOutput.php
includes/registration/ExtensionProcessor.php
includes/specials/SpecialTrackingCategories.php

index 0b0c7d0..8060983 100644 (file)
@@ -3855,20 +3855,12 @@ $wgNamespacesWithSubpages = array(
  * A message with the suffix '-desc' should be added as a description message
  * to have extra information on Special:TrackingCategories.
  *
+ * @deprecated since 1.25 Extensions should now register tracking categories using
+ *                        the new extension registration system.
+ *
  * @since 1.23
  */
-$wgTrackingCategories = array(
-       'index-category',
-       'noindex-category',
-       'duplicate-args-category',
-       'expensive-parserfunction-category',
-       'post-expand-template-argument-category',
-       'post-expand-template-inclusion-category',
-       'hidden-category-category',
-       'broken-file-category',
-       'node-count-exceeded-category',
-       'expansion-depth-exceeded-category',
-);
+$wgTrackingCategories = array();
 
 /**
  * Array of namespaces which can be deemed to contain valid "content", as far
index 117e04a..e9e72be 100644 (file)
@@ -489,9 +489,10 @@ class ParserOutput extends CacheTime {
         * Add a tracking category, getting the title from a system message,
         * or print a debug message if the title is invalid.
         *
-        * Please add any message that you use with this function to
-        * $wgTrackingCategories. That way they will be listed on
-        * Special:TrackingCategories.
+        * Any message used with this function should be registered so it will
+        * show up on Special:TrackingCategories. Core messages should be added
+        * to SpecialTrackingCategories::$coreTrackingCategories, and extensions
+        * should add to "TrackingCategories" in their extension.json.
         *
         * @param string $msg Message key
         * @param Title $title title of the page which is being tracked
index 14fc532..fe86ca9 100644 (file)
@@ -11,7 +11,6 @@ class ExtensionProcessor implements Processor {
                'ResourceLoaderSources',
                'ResourceLoaderLESSVars',
                'ResourceLoaderLESSImportPaths',
-               'TrackingCategories',
                'DefaultUserOptions',
                'HiddenPrefs',
                'GroupPermissions',
index 7684c05..d219c99 100644 (file)
@@ -36,6 +36,24 @@ class SpecialTrackingCategories extends SpecialPage {
                parent::__construct( 'TrackingCategories' );
        }
 
+       /**
+        * Tracking categories that exist in core
+        *
+        * @var array
+        */
+       private static $coreTrackingCategories = array(
+               'index-category',
+               'noindex-category',
+               'duplicate-args-category',
+               'expensive-parserfunction-category',
+               'post-expand-template-argument-category',
+               'post-expand-template-inclusion-category',
+               'hidden-category-category',
+               'broken-file-category',
+               'node-count-exceeded-category',
+               'expansion-depth-exceeded-category',
+       );
+
        function execute( $par ) {
                $this->setHeaders();
                $this->outputHeader();
@@ -120,8 +138,13 @@ class SpecialTrackingCategories extends SpecialPage {
         * @return array Array( 'msg' => Title, 'cats' => Title[] )
         */
        private function prepareTrackingCategoriesData() {
+               $categories = array_merge(
+                       self::$coreTrackingCategories,
+                       ExtensionRegistry::getInstance()->getAttribute( 'TrackingCategories' ),
+                       $this->getConfig()->get( 'TrackingCategories' ) // deprecated
+               );
                $trackingCategories = array();
-               foreach ( $this->getConfig()->get( 'TrackingCategories' ) as $catMsg ) {
+               foreach ( $categories as $catMsg ) {
                        /*
                         * Check if the tracking category varies by namespace
                         * Otherwise only pages in the current namespace will be displayed