From: Sam Reed Date: Mon, 6 Jun 2011 14:06:37 +0000 (+0000) Subject: Make ApiFeedWatchlist obey $wgFeed, and also die with an error if an invalid feed... X-Git-Tag: 1.31.0-rc.0~29671 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=59c87066fbe5a7bd262abe8495738f0f608b8944;p=lhc%2Fweb%2Fwiklou.git Make ApiFeedWatchlist obey $wgFeed, and also die with an error if an invalid feed formatter is given --- diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index d8c1019ba4..83cea0cb38 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -56,11 +56,19 @@ class ApiFeedWatchlist extends ApiBase { * Wrap the result as an RSS/Atom feed. */ public function execute() { - global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode; + global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode; try { $params = $this->extractRequestParams(); + if( !$wgFeed ) { + $this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' ); + } + + if( !isset( $wgFeedClasses[ $params['feed'] ] ) ) { + $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' ); + } + // limit to the number of hours going from now back $endTime = wfTimestamp( TS_MW, time() - intval( $params['hours'] * 60 * 60 ) ); @@ -197,6 +205,13 @@ class ApiFeedWatchlist extends ApiBase { return 'Returns a watchlist feed'; } + public function getPossibleErrors() { + return array_merge( parent::getPossibleErrors(), array( + array( 'code' => 'feed-unavailable', 'info' => 'Syndication feeds are not available' ), + array( 'code' => 'feed-invalid', 'info' => 'Invalid subscription feed type' ), + ) ); + } + protected function getExamples() { return array( 'api.php?action=feedwatchlist',