Merge "Refactor Watchlist code so mobile can be more consistent"
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
index 3515a57..76f2f4a 100644 (file)
@@ -137,7 +137,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
@@ -554,23 +554,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();
 
@@ -779,8 +782,8 @@ class EditWatchlistCheckboxSeriesField extends HTMLMultiSelectField {
         * form is open (bug 32126), but we know that invalid items will
         * be harmless so we can override it here.
         *
-        * @param string $value the value the field was submitted with
-        * @param array $alldata the data collected from the form
+        * @param string $value The value the field was submitted with
+        * @param array $alldata The data collected from the form
         * @return bool|string Bool true on success, or String error to display.
         */
        function validate( $value, $alldata ) {