Fixes to Special:TrackingCategories
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 17 Apr 2014 10:34:20 +0000 (12:34 +0200)
committerReedy <reedy@wikimedia.org>
Thu, 19 Jun 2014 09:28:32 +0000 (09:28 +0000)
- 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

includes/specials/SpecialTrackingCategories.php

index 98e92e4..bea65ba 100644 (file)
@@ -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();
                        }
 
                        /*