From 8185ade8f7398c6d0d1dd7401c4e91c35bff5de1 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Tue, 1 Jul 2014 20:22:38 +0200 Subject: [PATCH] SpecialEditWatchlist: Avoid empty namespace sections When the database contains a title for a positive namespace which is no longer active, a table of contents item and a empty section is shown on Special:EditWatchlist. After reload the section is gone, because the database was cleaned up and the invalid namespace can no longer produce the section. Refactor a bit to avoid the empty section on the first view as well to get a stable output of that special page. Change-Id: I41426bde71b21a4abddb12af0b3a84931f51ac97 --- includes/specials/SpecialEditWatchlist.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 0896929a66..6c258e0879 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -538,23 +538,26 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $count = 0; foreach ( $this->getWatchlistInfo() as $namespace => $pages ) { - if ( $namespace >= 0 ) { - $fields['TitlesNs' . $namespace] = array( - 'class' => 'EditWatchlistCheckboxSeriesField', - 'options' => array(), - 'section' => "ns$namespace", - ); - } + $options = array(); foreach ( array_keys( $pages ) as $dbkey ) { $title = Title::makeTitleSafe( $namespace, $dbkey ); if ( $this->checkTitle( $title, $namespace, $dbkey ) ) { $text = $this->buildRemoveLine( $title ); - $fields['TitlesNs' . $namespace]['options'][$text] = $title->getPrefixedText(); + $options[$text] = $title->getPrefixedText(); $count++; } } + + // checkTitle can filter some options out, avoid empty sections + if ( count( $options ) > 0 ) { + $fields['TitlesNs' . $namespace] = array( + 'class' => 'EditWatchlistCheckboxSeriesField', + 'options' => $options, + 'section' => "ns$namespace", + ); + } } $this->cleanupWatchlist(); -- 2.20.1