http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89562
Revision: 89562
Author: reedy
Date: 2011-06-06 14:06:37 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
Make ApiFeedWatchlist obey $wgFeed, and also die with an error if an invalid
feed formatter is given
Modified Paths:
--------------
trunk/phase3/includes/api/ApiFeedWatchlist.php
Modified: trunk/phase3/includes/api/ApiFeedWatchlist.php
===================================================================
--- trunk/phase3/includes/api/ApiFeedWatchlist.php 2011-06-06 12:18:01 UTC
(rev 89561)
+++ trunk/phase3/includes/api/ApiFeedWatchlist.php 2011-06-06 14:06:37 UTC
(rev 89562)
@@ -56,11 +56,19 @@
* 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 @@
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',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs