X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFormatFeedWrapper.php;h=d2bfd48d33c7870ab079df4a394c172eb5bbfcfa;hb=f43fa6f4f0e2cb60b8543daad661b48a3e0653a9;hp=92600067f1819782bc3ab02bb610c11f9b790ddf;hpb=5c115a77890ce370d04eafd89005a028b9de8a40;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFormatFeedWrapper.php b/includes/api/ApiFormatFeedWrapper.php index 92600067f1..d2bfd48d33 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 ); } /** @@ -59,15 +59,6 @@ class ApiFormatFeedWrapper extends ApiFormatBase { return null; } - /** - * Optimization - no need to sanitize data that will not be needed - * - * @return bool - */ - public function getNeedsRawData() { - return true; - } - /** * ChannelFeed doesn't give us a method to print errors in a friendly * manner, so just punt errors to the default printer. @@ -77,22 +68,46 @@ class ApiFormatFeedWrapper extends ApiFormatBase { return false; } + /** + * 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 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' );