Merge "Remove useless test in getParamValue function of mediawiki.util.js"
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
index fa48317..67f6d68 100644 (file)
@@ -3,10 +3,34 @@
  * @defgroup Watchlist Users watchlist handling
  */
 
+/**
+ * Implements Special:EditWatchlist
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup SpecialPage
+ * @ingroup Watchlist
+ */
+
 /**
  * Provides the UI through which users can perform editing
  * operations on their watchlist
  *
+ * @ingroup SpecialPage
  * @ingroup Watchlist
  * @author Rob Church <robchur@gmail.com>
  */
@@ -217,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__
@@ -253,7 +278,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        array( 'wl_namespace',  'wl_title' ),
                        array( 'wl_user' => $this->getUser()->getId() ),
                        __METHOD__,
-                       array( 'ORDER BY' => 'wl_namespace, wl_title' )
+                       array( 'ORDER BY' => array( 'wl_namespace', 'wl_title' ) )
                );
 
                $lb = new LinkBatch();
@@ -297,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,
                                ),
@@ -315,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 );
                        }
                }
        }
@@ -446,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++;
                                }
                        }