Merge "Soft deprecate DeferredStringifier class"
[lhc/web/wiklou.git] / includes / api / ApiFeedRecentChanges.php
index 5c0a4af..e5dba8f 100644 (file)
@@ -47,24 +47,24 @@ class ApiFeedRecentChanges extends ApiBase {
                $this->params = $this->extractRequestParams();
 
                if ( !$config->get( 'Feed' ) ) {
-                       $this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' );
+                       $this->dieWithError( 'feed-unavailable' );
                }
 
                $feedClasses = $config->get( 'FeedClasses' );
                if ( !isset( $feedClasses[$this->params['feedformat']] ) ) {
-                       $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' );
+                       $this->dieWithError( 'feed-invalid' );
                }
 
                $this->getMain()->setCacheMode( 'public' );
                if ( !$this->getMain()->getParameter( 'smaxage' ) ) {
-                       // bug 63249: This page gets hit a lot, cache at least 15 seconds.
+                       // T65249: This page gets hit a lot, cache at least 15 seconds.
                        $this->getMain()->setCacheMaxAge( 15 );
                }
 
                $feedFormat = $this->params['feedformat'];
                $specialClass = $this->params['target'] !== null
-                       ? 'SpecialRecentchangeslinked'
-                       : 'SpecialRecentchanges';
+                       ? SpecialRecentChangesLinked::class
+                       : SpecialRecentChanges::class;
 
                $formatter = $this->getFeedObject( $feedFormat, $specialClass );
 
@@ -81,7 +81,7 @@ class ApiFeedRecentChanges extends ApiBase {
                $rc->setContext( $context );
                $rows = $rc->getRows();
 
-               $feedItems = $rows ? ChangesFeed::buildItems( $rows ) : array();
+               $feedItems = $rows ? ChangesFeed::buildItems( $rows ) : [];
 
                ApiFormatFeedWrapper::setResult( $this->getResult(), $formatter, $feedItems );
        }
@@ -90,15 +90,15 @@ class ApiFeedRecentChanges extends ApiBase {
         * Return a ChannelFeed object.
         *
         * @param string $feedFormat Feed's format (either 'rss' or 'atom')
-        * @param string $specialClass Relevant special page name (either 'SpecialRecentchanges' or
-        *     'SpecialRecentchangeslinked')
+        * @param string $specialClass Relevant special page name (either 'SpecialRecentChanges' or
+        *     'SpecialRecentChangesLinked')
         * @return ChannelFeed
         */
        public function getFeedObject( $feedFormat, $specialClass ) {
-               if ( $specialClass === 'SpecialRecentchangeslinked' ) {
+               if ( $specialClass === SpecialRecentChangesLinked::class ) {
                        $title = Title::newFromText( $this->params['target'] );
                        if ( !$title ) {
-                               $this->dieUsageMsg( array( 'invalidtitle', $this->params['target'] ) );
+                               $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $this->params['target'] ) ] );
                        }
 
                        $feed = new ChangesFeed( $feedFormat, false );
@@ -124,32 +124,32 @@ class ApiFeedRecentChanges extends ApiBase {
                $config = $this->getConfig();
                $feedFormatNames = array_keys( $config->get( 'FeedClasses' ) );
 
-               $ret = array(
-                       'feedformat' => array(
+               $ret = [
+                       'feedformat' => [
                                ApiBase::PARAM_DFLT => 'rss',
                                ApiBase::PARAM_TYPE => $feedFormatNames,
-                       ),
+                       ],
 
-                       'namespace' => array(
+                       'namespace' => [
                                ApiBase::PARAM_TYPE => 'namespace',
-                       ),
+                       ],
                        'invert' => false,
                        'associated' => false,
 
-                       'days' => array(
+                       'days' => [
                                ApiBase::PARAM_DFLT => 7,
                                ApiBase::PARAM_MIN => 1,
                                ApiBase::PARAM_TYPE => 'integer',
-                       ),
-                       'limit' => array(
+                       ],
+                       'limit' => [
                                ApiBase::PARAM_DFLT => 50,
                                ApiBase::PARAM_MIN => 1,
                                ApiBase::PARAM_MAX => $config->get( 'FeedLimit' ),
                                ApiBase::PARAM_TYPE => 'integer',
-                       ),
-                       'from' => array(
+                       ],
+                       'from' => [
                                ApiBase::PARAM_TYPE => 'timestamp',
-                       ),
+                       ],
 
                        'hideminor' => false,
                        'hidebots' => false,
@@ -159,35 +159,25 @@ class ApiFeedRecentChanges extends ApiBase {
                        'hidemyself' => false,
                        'hidecategorization' => false,
 
-                       'tagfilter' => array(
+                       'tagfilter' => [
                                ApiBase::PARAM_TYPE => 'string',
-                       ),
+                       ],
 
-                       'target' => array(
+                       'target' => [
                                ApiBase::PARAM_TYPE => 'string',
-                       ),
+                       ],
                        'showlinkedto' => false,
-               );
-
-               if ( $config->get( 'AllowCategorizedRecentChanges' ) ) {
-                       $ret += array(
-                               'categories' => array(
-                                       ApiBase::PARAM_TYPE => 'string',
-                                       ApiBase::PARAM_ISMULTI => true,
-                               ),
-                               'categories_any' => false,
-                       );
-               }
+               ];
 
                return $ret;
        }
 
        protected function getExamplesMessages() {
-               return array(
+               return [
                        'action=feedrecentchanges'
                                => 'apihelp-feedrecentchanges-example-simple',
                        'action=feedrecentchanges&days=30'
                                => 'apihelp-feedrecentchanges-example-30days',
-               );
+               ];
        }
 }