Legoktm has submitted this change and it was merged.
Change subject: SpecialTrackingCategories: Read from the extension registry
......................................................................
SpecialTrackingCategories: Read from the extension registry
This demonstrates how we can transition from extensions putting
things into the global scope ($wgTrackingCategories) to instead
storing them in the extension registry. This will increase the
overall performance of the extension registry since it no
longer needs to do an array_merge with $wgTrackingCategories.
For extensions already converted to using the registry
no change is needed as the schema is still the same.
Change-Id: Ie0df4c20b123dac784a1c02eb991edc609a911b6
---
M includes/DefaultSettings.php
M includes/parser/ParserOutput.php
M includes/registration/ExtensionProcessor.php
M includes/specials/SpecialTrackingCategories.php
4 files changed, 32 insertions(+), 17 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index ee462d8..6d399cf 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -3845,20 +3845,12 @@
* 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
diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index 117e04a..e9e72be 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -489,9 +489,10 @@
* 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
diff --git a/includes/registration/ExtensionProcessor.php
b/includes/registration/ExtensionProcessor.php
index 459d95b..27c8148 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -11,7 +11,6 @@
'ResourceLoaderSources',
'ResourceLoaderLESSVars',
'ResourceLoaderLESSImportPaths',
- 'TrackingCategories',
'DefaultUserOptions',
'HiddenPrefs',
'GroupPermissions',
diff --git a/includes/specials/SpecialTrackingCategories.php
b/includes/specials/SpecialTrackingCategories.php
index 7684c05..d219c99 100644
--- a/includes/specials/SpecialTrackingCategories.php
+++ b/includes/specials/SpecialTrackingCategories.php
@@ -36,6 +36,24 @@
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 @@
* @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
--
To view, visit https://gerrit.wikimedia.org/r/180554
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie0df4c20b123dac784a1c02eb991edc609a911b6
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Brian Wolff <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits