* does this check, it makes since to use $ifWritesSince, particularly if
* cluster is "*", to avoid excess overhead.
*
- * Never call this method after a big DB write that is still in a transaction.
+ * Never call this function after a big DB write that is still in a transaction.
* This only makes sense after the possible lag inducing changes were committed.
*
* @param float|null $ifWritesSince Only wait if writes were done since this UNIX timestamp
// Prevents permission error when getting master position
if ( $lb->getServerCount() > 1 ) {
if ( $ifWritesSince && !$lb->hasMasterConnection() ) {
- break; // assume no writes done
+ continue; // assume no writes done
}
$dbw = $lb->getConnection( DB_MASTER, array(), $wiki );
if ( $ifWritesSince && $dbw->lastDoneWrites() < $ifWritesSince ) {
- break; // no writes since the last wait
+ continue; // no writes since the last wait
}
$pos = $dbw->getMasterPos();
// The DBMS may not support getMasterPos() or the whole
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
$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' );