Followup r78924: keep track of exception/warning comments separately, to prevent...
[lhc/web/wiklou.git] / includes / WatchlistEditor.php
index 8b089d0..b5a994d 100644 (file)
@@ -186,7 +186,7 @@ class WatchlistEditor {
                        __METHOD__
                );
                if( $res->numRows() > 0 ) {
-                       while( $row = $res->fetchObject() ) {
+                       foreach ( $res as $row ) {
                                $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
                                if( $title instanceof Title && !$title->isTalkPage() )
                                        $list[] = $title->getPrefixedText();
@@ -207,18 +207,20 @@ class WatchlistEditor {
        private function getWatchlistInfo( $user ) {
                $titles = array();
                $dbr = wfGetDB( DB_MASTER );
-               $uid = intval( $user->getId() );
-               list( $watchlist, $page ) = $dbr->tableNamesN( 'watchlist', 'page' );
-               $sql = "SELECT wl_namespace, wl_title, page_id, page_len, page_is_redirect, page_latest
-                       FROM {$watchlist} LEFT JOIN {$page} ON ( wl_namespace = page_namespace
-                       AND wl_title = page_title ) WHERE wl_user = {$uid}";
-               if ( ! $dbr->implicitOrderby() ) {
-                       $sql .= " ORDER BY wl_title";
-               }
-               $res = $dbr->query( $sql, __METHOD__ );
+
+               $res = $dbr->select(
+                                       array( 'watchlist', 'page' ),
+                                       array( 'wl_namespace', 'wl_title', 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ),
+                                       array( 'wl_user' => $user->getId() ),
+                                       __METHOD__,
+                                       array( 'ORDER BY' => 'wl_namespace, wl_title' ),
+                                       array( 'page' =>
+                                               array( 'LEFT JOIN', 'wl_namespace = page_namespace AND wl_title = page_title' ) )
+                               );
+
                if( $res && $dbr->numRows( $res ) > 0 ) {
                        $cache = LinkCache::singleton();
-                       while( $row = $dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {                      
                                $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
                                if( $title instanceof Title ) {
                                        // Update the link cache while we're at it
@@ -347,11 +349,12 @@ class WatchlistEditor {
         */
        private function showNormalForm( $output, $user ) {
                global $wgUser;
-               if( ( $count = $this->showItemCount( $output, $user ) ) > 0 ) {
+               $count = $this->showItemCount( $output, $user );
+               if( $count > 0 ) {
                        $self = SpecialPage::getTitleFor( 'Watchlist' );
                        $form  = Xml::openElement( 'form', array( 'method' => 'post',
                                'action' => $self->getLocalUrl( array( 'action' => 'edit' ) ) ) );
-                       $form .= Xml::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) );
+                       $form .= Html::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) );
                        $form .= "<fieldset>\n<legend>" . wfMsgHtml( 'watchlistedit-normal-legend' ) . "</legend>";
                        $form .= wfMsgExt( 'watchlistedit-normal-explain', 'parse' );
                        $form .= $this->buildRemoveList( $user, $wgUser->getSkin() );
@@ -460,9 +463,9 @@ class WatchlistEditor {
                global $wgUser;
                $this->showItemCount( $output, $user );
                $self = SpecialPage::getTitleFor( 'Watchlist' );
-               $form  = Xml::openElement( 'form', array( 'method' => 'post',
+               $form = Xml::openElement( 'form', array( 'method' => 'post',
                        'action' => $self->getLocalUrl( array( 'action' => 'raw' ) ) ) );
-               $form .= Xml::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) );
+               $form .= Html::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) );
                $form .= '<fieldset><legend>' . wfMsgHtml( 'watchlistedit-raw-legend' ) . '</legend>';
                $form .= wfMsgExt( 'watchlistedit-raw-explain', 'parse' );
                $form .= Xml::label( wfMsg( 'watchlistedit-raw-titles' ), 'titles' );