Merge "Revert "Adding sanity check to Title::isRedirect().""
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
index b7f1e61..3d43831 100644 (file)
@@ -241,8 +241,9 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $dbr = wfGetDB( DB_MASTER );
                $res = $dbr->select(
                        'watchlist',
-                       '*',
                        array(
+                               'wl_namespace', 'wl_title'
+                       ), array(
                                'wl_user' => $this->getUser()->getId(),
                        ),
                        __METHOD__
@@ -321,16 +322,20 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         * Attempts to clean up broken items
         */
        private function cleanupWatchlist() {
+               if( !count( $this->badItems ) ) {
+                       return; //nothing to do
+               }
                $dbw = wfGetDB( DB_MASTER );
+               $user = $this->getUser();
                foreach ( $this->badItems as $row ) {
                        list( $title, $namespace, $dbKey ) = $row;
-                       wfDebug( "User {$this->getUser()} has broken watchlist item ns($namespace):$dbKey, "
+                       wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, "
                                . ( $title ? 'cleaning up' : 'deleting' ) . ".\n"
                        );
 
                        $dbw->delete( 'watchlist',
                                array(
-                                       'wl_user' => $this->getUser()->getId(),
+                                       'wl_user' => $user->getId(),
                                        'wl_namespace' => $namespace,
                                        'wl_title' => $dbKey,
                                ),
@@ -339,7 +344,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
                        // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
                        if ( $title ) {
-                               $this->getUser()->addWatch( $title );
+                               $user->addWatch( $title );
                        }
                }
        }