Merge "Avoid useless delay and master connections in wfWaitForSlaves() in runJobs...
[lhc/web/wiklou.git] / includes / specials / SpecialTrackingCategories.php
index 8a32ba9..73bdbd6 100644 (file)
@@ -59,7 +59,7 @@ class SpecialTrackingCategories extends SpecialPage {
                        </tr></thead>"
                );
 
-               foreach( $wgTrackingCategories as $catMsg ) {
+               foreach ( $wgTrackingCategories as $catMsg ) {
                        /*
                         * Check if the tracking category varies by namespace
                         * Otherwise only pages in the current namespace will be displayed
@@ -69,18 +69,42 @@ class SpecialTrackingCategories extends SpecialPage {
                        $allMsgs = array();
                        $catDesc = $catMsg . '-desc';
                        $catMsgTitle = Title::makeTitleSafe( NS_MEDIAWIKI, $catMsg );
+                       if ( !$catMsgTitle ) {
+                               continue;
+                       }
                        $catMsgTitleText = Linker::link(
                                $catMsgTitle,
                                htmlspecialchars( $catMsg )
                        );
 
-                       if ( strpos( $msgObj->plain(), '{{NAMESPACE}}' ) !== false ) {
+                       // Match things like {{NAMESPACE}} and {{NAMESPACENUMBER}}.
+                       // False positives are ok, this is just an efficiency shortcut
+                       if ( strpos( $msgObj->plain(), '{{' ) !== false ) {
                                $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 )
@@ -88,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();
                        }
 
                        /*