Big oops - merged to wrong branch.
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
index b7f1e61..67f6d68 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 );
                        }
                }
        }
@@ -470,7 +475,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                                $title = Title::makeTitleSafe( $namespace, $dbkey );
                                if ( $this->checkTitle( $title, $namespace, $dbkey ) ) {
                                        $text = $this->buildRemoveLine( $title );
-                                       $fields['TitlesNs'.$namespace]['options'][$text] = $title->getEscapedText();
+                                       $fields['TitlesNs'.$namespace]['options'][$text] = htmlspecialchars( $title->getPrefixedText() );
                                        $count++;
                                }
                        }