(bug 31674) Can't edit watchlist if it contains special pages
authorMax Semenik <maxsem@users.mediawiki.org>
Sat, 15 Oct 2011 21:06:34 +0000 (21:06 +0000)
committerMax Semenik <maxsem@users.mediawiki.org>
Sat, 15 Oct 2011 21:06:34 +0000 (21:06 +0000)
RELEASE-NOTES-1.18
includes/User.php
includes/api/ApiWatch.php
includes/specials/SpecialEditWatchlist.php

index 074ff90..1976626 100644 (file)
@@ -469,6 +469,7 @@ production.
   really small, and somewhat inconsistent with each other.
 * (bug 30466) Entries in iwlinks table are now cleared when moving a page over
   redirect
+* (bug 31674) Can't edit watchlist if it contains special pages
 
 === API changes in 1.18 ===
 * BREAKING CHANGE: action=watch now requires POST and token.
@@ -697,17 +698,17 @@ Documentation for both end-users and site administrators is available on
 MediaWiki.org, and is covered under the GNU Free Documentation License (except
 for pages that explicitly state that their contents are in the public domain):
 
-       http://www.mediawiki.org/wiki/Documentation
+    http://www.mediawiki.org/wiki/Documentation
 
 == Mailing list ==
 
 A mailing list is available for MediaWiki user support and discussion:
 
-       http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
+    http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
 
 A low-traffic announcements-only list is also available:
 
-       http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce
+    http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce
 
 It's highly recommended that you sign up for one of these lists if you're
 going to run a public MediaWiki, so you can be notified of security fixes.
index 3710694..ad3ba03 100644 (file)
@@ -2605,6 +2605,14 @@ class User {
                $this->invalidateCache();
        }
 
+       /**
+        * Cleans up watchlist by removing invalid entries from it
+        */
+       public function cleanupWatchlist() {
+               $dbw = wfGetDB( DB_MASTER );
+               $dbw->delete( 'watchlist', array( 'wl_namespace < 0', 'wl_user' => $this->getId() ), __METHOD__ );
+       }
+
        /**
         * Clear the user's notification timestamp for the given title.
         * If e-notif e-mails are on, they will receive notification mails on
index 13220cb..9eee495 100644 (file)
@@ -49,7 +49,7 @@ class ApiWatch extends ApiBase {
                $params = $this->extractRequestParams();
                $title = Title::newFromText( $params['title'] );
 
-               if ( !$title ) {
+               if ( !$title || $titile->getNamespace() < 0 ) {
                        $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
                }
 
index 5b9dd7c..f0314a7 100644 (file)
@@ -376,8 +376,13 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
                $fields = array();
 
+               $haveInvalidNamespaces = false;
                foreach( $this->getWatchlistInfo() as $namespace => $pages ){
-
+                       if ( $namespace < 0 ) {
+                               $haveInvalidNamespaces = true;
+                               continue;
+                       }
+               
                        $namespace == NS_MAIN
                                ? wfMsgHtml( 'blanknamespace' )
                                : htmlspecialchars( $wgContLang->getFormattedNsText( $namespace ) );
@@ -394,6 +399,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                                $fields['TitlesNs'.$namespace]['options'][$text] = $title->getEscapedText();
                        }
                }
+               if ( $haveInvalidNamespaces ) {
+                       wfDebug( "User {$this->getContext()->getUser()->getId()} has invalid watchlist entries, clening up...\n" );
+                       $this->getContext()->getUser()->cleanupWatchlist();
+               }
 
                $form = new EditWatchlistNormalHTMLForm( $fields, $this->getContext() );
                $form->setTitle( $this->getTitle() );