Merge "ChangesListSpecialPage: Implement doMainQuery()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 30 Jan 2014 19:55:49 +0000 (19:55 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 30 Jan 2014 19:55:49 +0000 (19:55 +0000)
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php

index c088adb..3a99eda 100644 (file)
@@ -269,13 +269,44 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
        /**
         * Process the query
-        * @todo This should build some basic processing hereā€¦
         *
         * @param array $conds
         * @param FormOptions $opts
-        * @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
+        * @return bool|ResultWrapper Result or false
         */
-       abstract public function doMainQuery( $conds, $opts );
+       public function doMainQuery( $conds, $opts ) {
+               $tables = array( 'recentchanges' );
+               $fields = RecentChange::selectFields();
+               $query_options = array();
+               $join_conds = array();
+
+               ChangeTags::modifyDisplayQuery(
+                       $tables,
+                       $fields,
+                       $conds,
+                       $join_conds,
+                       $query_options,
+                       ''
+               );
+
+               // @todo Fire a Special{$this->getName()}Query hook here
+               // @todo Uncomment and document
+               // if ( !wfRunHooks( 'ChangesListSpecialPageQuery',
+               //      array( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) )
+               // ) {
+               //      return false;
+               // }
+
+               $dbr = $this->getDB();
+               return $dbr->select(
+                       $tables,
+                       $fields,
+                       $conds,
+                       __METHOD__,
+                       $query_options,
+                       $join_conds
+               );
+       }
 
        /**
         * Return a DatabaseBase object for reading
index fdf8dcb..36a1d1c 100644 (file)
@@ -182,35 +182,32 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         * @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
         */
        public function doMainQuery( $conds, $opts ) {
-               $tables = array( 'recentchanges' );
-               $join_conds = array();
-               $query_options = array();
-
-               $uid = $this->getUser()->getId();
                $dbr = $this->getDB();
-               $limit = $opts['limit'];
-               $namespace = $opts['namespace'];
-               $invert = $opts['invert'];
-               $associated = $opts['associated'];
+               $user = $this->getUser();
 
+               $tables = array( 'recentchanges' );
                $fields = RecentChange::selectFields();
+               $query_options = array();
+               $join_conds = array();
+
                // JOIN on watchlist for users
-               if ( $uid && $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
+               if ( $user->getId() && $user->isAllowed( 'viewmywatchlist' ) ) {
                        $tables[] = 'watchlist';
                        $fields[] = 'wl_user';
                        $fields[] = 'wl_notificationtimestamp';
                        $join_conds['watchlist'] = array( 'LEFT JOIN', array(
-                               'wl_user' => $uid,
+                               'wl_user' => $user->getId(),
                                'wl_title=rc_title',
                                'wl_namespace=rc_namespace'
                        ) );
                }
-               if ( $this->getUser()->isAllowed( 'rollback' ) ) {
+
+               if ( $user->isAllowed( 'rollback' ) ) {
                        $tables[] = 'page';
                        $fields[] = 'page_latest';
                        $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
                }
-               // Tag stuff.
+
                ChangeTags::modifyDisplayQuery(
                        $tables,
                        $fields,
@@ -233,7 +230,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        $fields,
                        $conds + array( 'rc_new' => array( 0, 1 ) ),
                        __METHOD__,
-                       array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + $query_options,
+                       array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $opts['limit'] ) + $query_options,
                        $join_conds
                );
        }
index a98447b..1477192 100644 (file)
@@ -178,6 +178,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                $dbr = $this->getDB();
                $user = $this->getUser();
+
                # Toggle watchlist content (all recent edits or just the latest)
                if ( $opts['extended'] ) {
                        $limitWatchlist = $user->getIntOption( 'wllimit' );
@@ -201,6 +202,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
 
                $tables = array( 'recentchanges', 'watchlist' );
                $fields = RecentChange::selectFields();
+               $query_options = array( 'ORDER BY' => 'rc_timestamp DESC' );
                $join_conds = array(
                        'watchlist' => array(
                                'INNER JOIN',
@@ -211,12 +213,12 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                ),
                        ),
                );
-               $options = array( 'ORDER BY' => 'rc_timestamp DESC' );
+
                if ( $wgShowUpdatedMarker ) {
                        $fields[] = 'wl_notificationtimestamp';
                }
                if ( $limitWatchlist ) {
-                       $options['LIMIT'] = $limitWatchlist;
+                       $query_options['LIMIT'] = $limitWatchlist;
                }
 
                $rollbacker = $user->isAllowed( 'rollback' );
@@ -245,10 +247,26 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                }
 
 
-               ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $options, '' );
-               wfRunHooks( 'SpecialWatchlistQuery', array( &$conds, &$tables, &$join_conds, &$fields, $opts ) );
+               ChangeTags::modifyDisplayQuery(
+                       $tables,
+                       $fields,
+                       $conds,
+                       $join_conds,
+                       $query_options,
+                       ''
+               );
 
-               return $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds );
+               wfRunHooks( 'SpecialWatchlistQuery',
+                       array( &$conds, &$tables, &$join_conds, &$fields, $opts ) );
+
+               return $dbr->select(
+                       $tables,
+                       $fields,
+                       $conds,
+                       __METHOD__,
+                       $query_options,
+                       $join_conds
+               );
        }
 
        /**