Merge "Suppress section edit links with action=render"
[lhc/web/wiklou.git] / includes / specialpage / ChangesListSpecialPage.php
index 03bc8c2..14ac401 100644 (file)
  * @ingroup SpecialPage
  */
 abstract class ChangesListSpecialPage extends SpecialPage {
-       var $rcSubpage, $rcOptions; // @todo Rename these, make protected
-       protected $customFilters;
+       /** @var string */
+       protected $rcSubpage;
 
-       /**
-        * The feed format to output as (either 'rss' or 'atom'), or null if no
-        * feed output was requested
-        *
-        * @var string $feedFormat
-        */
-       protected $feedFormat;
+       /** @var FormOptions */
+       protected $rcOptions;
+
+       /** @var array */
+       protected $customFilters;
 
        /**
         * Main execution point
@@ -46,19 +44,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
         */
        public function execute( $subpage ) {
                $this->rcSubpage = $subpage;
-               $this->feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' );
-               if ( $this->feedFormat !== 'atom' && $this->feedFormat !== 'rss' ) {
-                       $this->feedFormat = null;
-               }
 
                $this->setHeaders();
                $this->outputHeader();
                $this->addModules();
 
+               $rows = $this->getRows();
                $opts = $this->getOptions();
-               // Fetch results, prepare a batch link existence check query
-               $conds = $this->buildMainQueryConds( $opts );
-               $rows = $this->doMainQuery( $conds, $opts );
                if ( $rows === false ) {
                        if ( !$this->including() ) {
                                $this->doHeader( $opts );
@@ -67,26 +59,31 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                        return;
                }
 
-               if ( !$this->feedFormat ) {
-                       $batch = new LinkBatch;
-                       foreach ( $rows as $row ) {
-                               $batch->add( NS_USER, $row->rc_user_text );
-                               $batch->add( NS_USER_TALK, $row->rc_user_text );
-                               $batch->add( $row->rc_namespace, $row->rc_title );
-                       }
-                       $batch->execute();
-               }
-               if ( $this->feedFormat ) {
-                       list( $changesFeed, $formatter ) = $this->getFeedObject( $this->feedFormat );
-                       /** @var ChangesFeed $changesFeed */
-                       $changesFeed->execute( $formatter, $rows, $this->checkLastModified( $this->feedFormat ), $opts );
-               } else {
-                       $this->webOutput( $rows, $opts );
+               $batch = new LinkBatch;
+               foreach ( $rows as $row ) {
+                       $batch->add( NS_USER, $row->rc_user_text );
+                       $batch->add( NS_USER_TALK, $row->rc_user_text );
+                       $batch->add( $row->rc_namespace, $row->rc_title );
                }
+               $batch->execute();
+
+               $this->webOutput( $rows, $opts );
 
                $rows->free();
        }
 
+       /**
+        * Get the database result for this special page instance. Used by ApiFeedRecentChanges.
+        *
+        * @return bool|ResultWrapper Result or false
+        */
+       public function getRows() {
+               $opts = $this->getOptions();
+               $conds = $this->buildMainQueryConds( $opts );
+
+               return $this->doMainQuery( $conds, $opts );
+       }
+
        /**
         * Get the current FormOptions for this request
         *
@@ -168,6 +165,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
         */
        protected function fetchOptionsFromRequest( $opts ) {
                $opts->fetchValuesFromRequest( $this->getRequest() );
+
                return $opts;
        }
 
@@ -192,7 +190,6 @@ abstract class ChangesListSpecialPage extends SpecialPage {
 
        /**
         * Return an array of conditions depending of options set in $opts
-        * @todo Whyyyy is this mutating $opts…
         *
         * @param FormOptions $opts
         * @return array
@@ -202,15 +199,15 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                $user = $this->getUser();
                $conds = array();
 
-               // It makes no sense to hide both anons and logged-in users
-               // Where this occurs, force anons to be shown
-               $botsOnly = false;
+               // It makes no sense to hide both anons and logged-in users. When this occurs, try a guess on
+               // what the user meant and either show only bots or force anons to be shown.
+               $botsonly = false;
+               $hideanons = $opts['hideanons'];
                if ( $opts['hideanons'] && $opts['hideliu'] ) {
-                       // Check if the user wants to show bots only
                        if ( $opts['hidebots'] ) {
-                               $opts['hideanons'] = false;
+                               $hideanons = false;
                        } else {
-                               $botsOnly = true;
+                               $botsonly = true;
                        }
                }
 
@@ -224,13 +221,13 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                if ( $user->useRCPatrol() && $opts['hidepatrolled'] ) {
                        $conds['rc_patrolled'] = 0;
                }
-               if ( $botsOnly ) {
+               if ( $botsonly ) {
                        $conds['rc_bot'] = 1;
                } else {
                        if ( $opts['hideliu'] ) {
                                $conds[] = 'rc_user = 0';
                        }
-                       if ( $opts['hideanons'] ) {
+                       if ( $hideanons ) {
                                $conds[] = 'rc_user != 0';
                        }
                }
@@ -298,6 +295,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                // }
 
                $dbr = $this->getDB();
+
                return $dbr->select(
                        $tables,
                        $fields,
@@ -462,30 +460,6 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                $out->addModules( 'mediawiki.special.changeslist.legend.js' );
        }
 
-       /**
-        * Return an array with a ChangesFeed object and ChannelFeed object.
-        *
-        * This is intentionally not abstract not to require subclasses which don't
-        * use feeds functionality to implement it.
-        *
-        * @param string $feedFormat Feed's format (either 'rss' or 'atom')
-        * @return array
-        */
-       public function getFeedObject( $feedFormat ) {
-               throw new MWException( "Not implemented" );
-       }
-
-       /**
-        * Get last-modified date, for client caching. Not implemented by default
-        * (returns current time).
-        *
-        * @param string $feedFormat
-        * @return string|bool
-        */
-       public function checkLastModified( $feedFormat ) {
-               return wfTimestampNow();
-       }
-
        protected function getGroupName() {
                return 'changes';
        }