Index: trunk/phase3/includes/api/ApiFeedWatchlist.php |
— | — | @@ -56,11 +56,19 @@ |
57 | 57 | * Wrap the result as an RSS/Atom feed. |
58 | 58 | */ |
59 | 59 | public function execute() { |
60 | | - global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode; |
| 60 | + global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgLanguageCode; |
61 | 61 | |
62 | 62 | try { |
63 | 63 | $params = $this->extractRequestParams(); |
64 | 64 | |
| 65 | + if( !$wgFeed ) { |
| 66 | + $this->dieUsage( 'Syndication feeds are not available', 'feed-unavailable' ); |
| 67 | + } |
| 68 | + |
| 69 | + if( !isset( $wgFeedClasses[ $params['feed'] ] ) ) { |
| 70 | + $this->dieUsage( 'Invalid subscription feed type', 'feed-invalid' ); |
| 71 | + } |
| 72 | + |
65 | 73 | // limit to the number of hours going from now back |
66 | 74 | $endTime = wfTimestamp( TS_MW, time() - intval( $params['hours'] * 60 * 60 ) ); |
67 | 75 | |
— | — | @@ -197,6 +205,13 @@ |
198 | 206 | return 'Returns a watchlist feed'; |
199 | 207 | } |
200 | 208 | |
| 209 | + public function getPossibleErrors() { |
| 210 | + return array_merge( parent::getPossibleErrors(), array( |
| 211 | + array( 'code' => 'feed-unavailable', 'info' => 'Syndication feeds are not available' ), |
| 212 | + array( 'code' => 'feed-invalid', 'info' => 'Invalid subscription feed type' ), |
| 213 | + ) ); |
| 214 | + } |
| 215 | + |
201 | 216 | protected function getExamples() { |
202 | 217 | return array( |
203 | 218 | 'api.php?action=feedwatchlist', |