API * Optimized revision <rev> tag setting
authorYuri Astrakhan <yurik@users.mediawiki.org>
Wed, 18 Oct 2006 05:35:24 +0000 (05:35 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Wed, 18 Oct 2006 05:35:24 +0000 (05:35 +0000)
includes/api/ApiQueryRevisions.php
includes/api/ApiResult.php

index 5fc5222..8e075bf 100644 (file)
@@ -224,12 +224,14 @@ class ApiQueryRevisions extends ApiQueryBase {
                }
                $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');
+                               }
                        }
                }
        }
index 6bee415..b56d7ac 100644 (file)
@@ -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');