diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:31:04 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-06-04 07:58:39 +0200 |
commit | f6d65e533c62f6deb21342d4901ece24497b433e (patch) | |
tree | f28adf0362d14bcd448f7b65a7aaf38650f923aa /includes/api/ApiFormatFeedWrapper.php | |
parent | c27b2e832fe25651ef2410fae85b41072aae7519 (diff) |
Update to MediaWiki 1.25.1
Diffstat (limited to 'includes/api/ApiFormatFeedWrapper.php')
-rw-r--r-- | includes/api/ApiFormatFeedWrapper.php | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/includes/api/ApiFormatFeedWrapper.php b/includes/api/ApiFormatFeedWrapper.php index 92600067..00747eef 100644 --- a/includes/api/ApiFormatFeedWrapper.php +++ b/includes/api/ApiFormatFeedWrapper.php @@ -46,8 +46,8 @@ class ApiFormatFeedWrapper extends ApiFormatBase { // Disable size checking for this because we can't continue // cleanly; size checking would cause more problems than it'd // solve - $result->addValue( null, '_feed', $feed, ApiResult::NO_SIZE_CHECK ); - $result->addValue( null, '_feeditems', $feedItems, ApiResult::NO_SIZE_CHECK ); + $result->addValue( null, '_feed', $feed, ApiResult::NO_VALIDATE ); + $result->addValue( null, '_feeditems', $feedItems, ApiResult::NO_VALIDATE ); } /** @@ -82,17 +82,41 @@ class ApiFormatFeedWrapper extends ApiFormatBase { * $result['_feed'] - an instance of one of the $wgFeedClasses classes * $result['_feeditems'] - an array of FeedItem instances */ + public function initPrinter( $unused = false ) { + parent::initPrinter( $unused ); + + if ( $this->isDisabled() ) { + return; + } + + $data = $this->getResult()->getResultData(); + if ( isset( $data['_feed'] ) && isset( $data['_feeditems'] ) ) { + $data['_feed']->httpHeaders(); + } else { + // Error has occurred, print something useful + ApiBase::dieDebug( __METHOD__, 'Invalid feed class/item' ); + } + } + + /** + * This class expects the result data to be in a custom format set by self::setResult() + * $result['_feed'] - an instance of one of the $wgFeedClasses classes + * $result['_feeditems'] - an array of FeedItem instances + */ public function execute() { - $data = $this->getResultData(); + $data = $this->getResult()->getResultData(); if ( isset( $data['_feed'] ) && isset( $data['_feeditems'] ) ) { $feed = $data['_feed']; $items = $data['_feeditems']; + // execute() needs to pass strings to $this->printText, not produce output itself. + ob_start(); $feed->outHeader(); foreach ( $items as & $item ) { $feed->outItem( $item ); } $feed->outFooter(); + $this->printText( ob_get_clean() ); } else { // Error has occurred, print something useful ApiBase::dieDebug( __METHOD__, 'Invalid feed class/item' ); |