From d732def31e40aa5547be9aaba966ab8c329284eb Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Sat, 19 May 2007 23:54:22 +0000 Subject: [PATCH] API: fixed bug in categories: error when no valid titles are given --- includes/api/ApiPageSet.php | 7 ++----- includes/api/ApiQueryCategories.php | 11 ++++++++++- includes/api/ApiQueryInfo.php | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index fc6ed7a856..d2f561040a 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -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 ( diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index 63defe21db..f27de7e30c 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -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); } diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index 5ed79fe000..26032262c5 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -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]) -- 2.20.1