From: Yuri Astrakhan Date: Wed, 18 Oct 2006 05:35:24 +0000 (+0000) Subject: API * Optimized revision tag setting X-Git-Tag: 1.31.0-rc.0~55447 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=e65974bc4f63bbec0c3f592c600708e479a0f78c;p=lhc%2Fweb%2Fwiklou.git API * Optimized revision tag setting --- diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 5fc52222a7..8e075bf557 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -224,12 +224,14 @@ class ApiQueryRevisions extends ApiQueryBase { } $db->freeResult($res); - // Ensure that all revisions are shown as '' elements + // Ensure that all revisions are shown as '' 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'); + } } } } diff --git a/includes/api/ApiResult.php b/includes/api/ApiResult.php index 6bee415334..b56d7ac658 100644 --- a/includes/api/ApiResult.php +++ b/includes/api/ApiResult.php @@ -31,14 +31,14 @@ if (!defined('MEDIAWIKI')) { 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(); } @@ -51,10 +51,14 @@ class ApiResult extends ApiBase { * 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; } @@ -108,7 +112,7 @@ class ApiResult extends ApiBase { */ 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');