}
$db->freeResult($res);
- // Ensure that all revisions are shown as '<r>' elements
+ // Ensure that all revisions are shown as '<rev>' elements
$result = $this->getResult();
- $data = & $result->getData();
- foreach ($data['query']['pages'] as & $page) {
- if (is_array($page) && array_key_exists('revisions', $page)) {
- $result->setIndexedTagName($page['revisions'], 'rev');
+ if( $result->getIsRawMode()) {
+ $data = & $result->getData();
+ foreach ($data['query']['pages'] as & $page) {
+ if (is_array($page) && array_key_exists('revisions', $page)) {
+ $result->setIndexedTagName($page['revisions'], 'rev');
+ }
}
}
}
class ApiResult extends ApiBase {
- private $mData, $mNeedsRaw;
+ private $mData, $mIsRawMode;
/**
* Constructor
*/
public function __construct($main) {
parent :: __construct($main, 'result');
- $this->mNeedsRaw = false;
+ $this->mIsRawMode = false;
$this->reset();
}
* are needed by the formatter, for example in XML printing.
*/
public function setRawMode() {
- $this->mNeedsRaw = true;
+ $this->mIsRawMode = true;
+ }
+
+ public function getIsRawMode() {
+ return $this->mIsRawMode;
}
- function & getData() {
+ public function & getData() {
return $this->mData;
}
*/
public function setIndexedTagName(& $arr, $tag) {
// In raw mode, add the '_element', otherwise just ignore
- if (!$this->mNeedsRaw)
+ if (!$this->getIsRawMode())
return;
if ($arr === null || $tag === null || !is_array($arr) || is_array($tag))
ApiBase :: dieDebug(__METHOD__, 'Bad parameter');