r17076 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17075‎ | r17076 | r17077 >
Date:05:35, 18 October 2006
Author:yurik
Status:old
Tags:
Comment:
API * Optimized revision <rev> tag setting
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiResult.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -224,12 +224,14 @@
225225 }
226226 $db->freeResult($res);
227227
228 - // Ensure that all revisions are shown as '<r>' elements
 228+ // Ensure that all revisions are shown as '<rev>' elements
229229 $result = $this->getResult();
230 - $data = & $result->getData();
231 - foreach ($data['query']['pages'] as & $page) {
232 - if (is_array($page) && array_key_exists('revisions', $page)) {
233 - $result->setIndexedTagName($page['revisions'], 'rev');
 230+ if( $result->getIsRawMode()) {
 231+ $data = & $result->getData();
 232+ foreach ($data['query']['pages'] as & $page) {
 233+ if (is_array($page) && array_key_exists('revisions', $page)) {
 234+ $result->setIndexedTagName($page['revisions'], 'rev');
 235+ }
234236 }
235237 }
236238 }
Index: trunk/phase3/includes/api/ApiResult.php
@@ -31,14 +31,14 @@
3232
3333 class ApiResult extends ApiBase {
3434
35 - private $mData, $mNeedsRaw;
 35+ private $mData, $mIsRawMode;
3636
3737 /**
3838 * Constructor
3939 */
4040 public function __construct($main) {
4141 parent :: __construct($main, 'result');
42 - $this->mNeedsRaw = false;
 42+ $this->mIsRawMode = false;
4343 $this->reset();
4444 }
4545
@@ -51,10 +51,14 @@
5252 * are needed by the formatter, for example in XML printing.
5353 */
5454 public function setRawMode() {
55 - $this->mNeedsRaw = true;
 55+ $this->mIsRawMode = true;
5656 }
 57+
 58+ public function getIsRawMode() {
 59+ return $this->mIsRawMode;
 60+ }
5761
58 - function & getData() {
 62+ public function & getData() {
5963 return $this->mData;
6064 }
6165
@@ -108,7 +112,7 @@
109113 */
110114 public function setIndexedTagName(& $arr, $tag) {
111115 // In raw mode, add the '_element', otherwise just ignore
112 - if (!$this->mNeedsRaw)
 116+ if (!$this->getIsRawMode())
113117 return;
114118 if ($arr === null || $tag === null || !is_array($arr) || is_array($tag))
115119 ApiBase :: dieDebug(__METHOD__, 'Bad parameter');