From 69810149c29a7c0b2c4aae78338b509f2f6c253c Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sun, 11 Oct 2009 12:52:08 +0000 Subject: [PATCH] (bug 21095) allow tracking categories added to the parser to be disabled by setting the system message to "-". --- RELEASE-NOTES | 3 +++ includes/parser/Parser.php | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index da4ce72d7c..ffa97c5be9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -245,6 +245,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13750) First letter capitalization can now be a per-namespace setting * (bug 21073) "User does not exist" message no longer displayed on sub-sub-pages of existing users +* (bug 21095) Tracking categories produced by the parser (expensive parser function + limit exceeded, __NOINDEX__ tracking, etc) can now be disabled by setting the + system message ([[MediaWiki:expensive-parserfunction-category]] etc) to "-". === Bug fixes in 1.16 === diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a076c4789e..c96ada40b6 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -2726,14 +2726,10 @@ class Parser * exceeded, provide the values (optional) */ function limitationWarn( $limitationType, $current=null, $max=null) { - $msgName = $limitationType . '-warning'; //does no harm if $current and $max are present but are unnecessary for the message - $warning = wfMsgExt( $msgName, array( 'parsemag', 'escape' ), $current, $max ); + $warning = wfMsgExt( "$limitationType-warning", array( 'parsemag', 'escape' ), $current, $max ); $this->mOutput->addWarning( $warning ); - $cat = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( $limitationType . '-category' ) ); - if ( $cat ) { - $this->mOutput->addCategory( $cat->getDBkey(), $this->getDefaultSort() ); - } + $this->addTrackingCategory( "$limitationType-category" ); } /** @@ -3426,7 +3422,12 @@ class Parser * @return Bool whether the addition was successful */ protected function addTrackingCategory( $msg ){ - $containerCategory = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( $msg ) ); + $cat = wfMsgForContent( $msg ); + + # Allow tracking categories to be disabled by setting them to "-" + if( $cat === '-' ) return false; + + $containerCategory = Title::makeTitleSafe( NS_CATEGORY, $cat ); if ( $containerCategory ) { $this->mOutput->addCategory( $containerCategory->getDBkey(), $this->getDefaultSort() ); return true; -- 2.20.1