API: fixed bug in categories: error when no valid titles are given
authorYuri Astrakhan <yurik@users.mediawiki.org>
Sat, 19 May 2007 23:54:22 +0000 (23:54 +0000)
committerYuri Astrakhan <yurik@users.mediawiki.org>
Sat, 19 May 2007 23:54:22 +0000 (23:54 +0000)
includes/api/ApiPageSet.php
includes/api/ApiQueryCategories.php
includes/api/ApiQueryInfo.php

index fc6ed7a..d2f5610 100644 (file)
@@ -88,7 +88,8 @@ class ApiPageSet extends ApiQueryBase {
                if ($this->mResolveRedirects)
                        $pageFlds['page_is_redirect'] = null;
 
-               return array_keys(array_merge($pageFlds, $this->mRequestedPageFields));
+               $pageFlds = array_merge($pageFlds, $this->mRequestedPageFields);
+               return array_keys($pageFlds);
        }
 
        /**
@@ -570,10 +571,6 @@ class ApiPageSet extends ApiQueryBase {
                return $linkBatch;
        }
        
-       public static function debugPrint($name = 'unknown') {
-               ApiBase::debugPrint($this->mAllPages, $name);
-       }
-
        protected function getAllowedParams() {
                return array (
                        'titles' => array (
index 63defe2..f27de7e 100644 (file)
@@ -47,6 +47,9 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
 
        private function run($resultPageSet = null) {
 
+               if ($this->getPageSet()->getGoodTitleCount() == 0)
+                       return; // nothing to do
+
                $params = $this->extractRequestParams();
                $prop = $params['prop'];
 
@@ -90,10 +93,14 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
                                }
                                
                                $title = Title :: makeTitle(NS_CATEGORY, $row->cl_to);
+                               // do not check userCanRead() -- page content is already accessible,
+                               // and category is listed there.
+                               
                                $vals = array();
                                ApiQueryBase :: addTitleInfo($vals, $title);
                                if ($fld_sortkey)
                                        $vals['sortkey'] = $row->cl_sortkey;
+
                                $data[] = $vals;
                        }
 
@@ -105,7 +112,9 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
 
                        $titles = array();
                        while ($row = $db->fetchObject($res)) {
-                               $titles[] = Title :: makeTitle(NS_CATEGORY, $row->cl_to);
+                               $title = Title :: makeTitle(NS_CATEGORY, $row->cl_to);
+                               if($title->userCanRead())
+                                       $titles[] = $title;
                        }
                        $resultPageSet->populateFromTitles($titles);
                }
index 5ed79fe..2603226 100644 (file)
@@ -64,8 +64,8 @@ class ApiQueryInfo extends ApiQueryBase {
                        $pageInfo = array (
                                'touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]),
                                'lastrevid' => intval($pageLatest[$pageid]),
-                               'counter' => $pageCounter[$pageid],
-                               'length' => $pageLength[$pageid],
+                               'counter' => intval($pageCounter[$pageid]),
+                               'length' => intval($pageLength[$pageid]),
                        );
 
                        if ($pageIsRedir[$pageid])