From: umherirrender Date: Tue, 1 Jul 2014 18:22:38 +0000 (+0200) Subject: SpecialEditWatchlist: Avoid empty namespace sections X-Git-Tag: 1.31.0-rc.0~14710^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=8185ade8f7398c6d0d1dd7401c4e91c35bff5de1;p=lhc%2Fweb%2Fwiklou.git 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 --- 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();