From 4ddd259d0d3b0399eb1e553d95125e53f30f1032 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 17 Apr 2014 12:34:20 +0200 Subject: [PATCH] Fixes to Special:TrackingCategories - Message::isDisabled is using the unparsed message text, so this is always true and not false when a #switch will return '-'. Using a compare against '-', the same as in Parser::addTrackingCategory. - Title::makeTitleSafe can return null, check that - Add 'trackingcategories-disabled' when array is empty, this can happen when a '{{' is given, but no categories was found Change-Id: I88322512db5c4baedc5c571ce9ccbcd0caebb61d --- .../specials/SpecialTrackingCategories.php | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/includes/specials/SpecialTrackingCategories.php b/includes/specials/SpecialTrackingCategories.php index 98e92e4000..bea65ba104 100644 --- a/includes/specials/SpecialTrackingCategories.php +++ b/includes/specials/SpecialTrackingCategories.php @@ -69,6 +69,9 @@ class SpecialTrackingCategories extends SpecialPage { $allMsgs = array(); $catDesc = $catMsg . '-desc'; $catMsgTitle = Title::makeTitleSafe( NS_MEDIAWIKI, $catMsg ); + if ( !$catMsgTitle ) { + continue; + } $catMsgTitleText = Linker::link( $catMsgTitle, htmlspecialchars( $catMsg ) @@ -80,9 +83,28 @@ class SpecialTrackingCategories extends SpecialPage { $ns = MWNamespace::getValidNamespaces(); foreach ( $ns as $namesp ) { $tempTitle = Title::makeTitleSafe( $namesp, $catMsg ); + if ( !$tempTitle ) { + continue; + } $catName = $msgObj->title( $tempTitle )->text(); - if ( !$msgObj->isDisabled() ) { + # Allow tracking categories to be disabled by setting them to "-" + if ( $catName !== '-' ) { $catTitle = Title::makeTitleSafe( NS_CATEGORY, $catName ); + if ( $catTitle ) { + $catTitleText = Linker::link( + $catTitle, + htmlspecialchars( $catName ) + ); + $allMsgs[] = $catTitleText; + } + } + } + } else { + $catName = $msgObj->text(); + # Allow tracking categories to be disabled by setting them to "-" + if ( $catName !== '-' ) { + $catTitle = Title::makeTitleSafe( NS_CATEGORY, $catName ); + if ( $catTitle ) { $catTitleText = Linker::link( $catTitle, htmlspecialchars( $catName ) @@ -90,18 +112,11 @@ class SpecialTrackingCategories extends SpecialPage { $allMsgs[] = $catTitleText; } } - } else { - $catName = $msgObj->text(); - if ( !$msgObj->isDisabled() ) { - $catTitle = Title::makeTitleSafe( NS_CATEGORY, $catName ); - $catTitleText = Linker::link( - $catTitle, - htmlspecialchars( $catName ) - ); - } else { - $catTitleText = $this->msg( 'trackingcategories-disabled' )->parse(); - } - $allMsgs[] = $catTitleText; + } + + # Extra message, when no category was found + if ( !count( $allMsgs ) ) { + $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse(); } /* -- 2.20.1