X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFormatFeedWrapper.php;h=3f53ed43d32959b96ba2b8bf639d20712a97201a;hb=524d92b61f2a951200b00326cfac6b25a830acb6;hp=92600067f1819782bc3ab02bb610c11f9b790ddf;hpb=d1b6cd35d4aa117c454994b4a7896fee8abf17d2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFormatFeedWrapper.php b/includes/api/ApiFormatFeedWrapper.php index 92600067f1..3f53ed43d3 100644 --- a/includes/api/ApiFormatFeedWrapper.php +++ b/includes/api/ApiFormatFeedWrapper.php @@ -77,6 +77,27 @@ 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->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 @@ -88,11 +109,14 @@ class ApiFormatFeedWrapper extends ApiFormatBase { $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' );