API: (bug 16647) list=allcategories, prop=categories don't return "hidden" property...
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 14 Dec 2008 20:24:23 +0000 (20:24 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 14 Dec 2008 20:24:23 +0000 (20:24 +0000)
RELEASE-NOTES
includes/api/ApiQueryAllCategories.php
includes/api/ApiQueryCategoryInfo.php

index bb2d957..c9eb852 100644 (file)
@@ -516,6 +516,8 @@ The following extensions are migrated into MediaWiki 1.14:
   protection wasn't allowed 
 * (bug 16626) action=delete now correctly handles empty "reason" param
 * (bug 15579) clshow considers all categories !hidden
+* (bug 16647) list=allcategories, prop=categories don't return "hidden"
+  property for hidden categories
 
 === Languages updated in 1.14 ===
 
index 9690ae3..b8c06e9 100644 (file)
@@ -67,7 +67,19 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
 
                $prop = array_flip($params['prop']);
                $this->addFieldsIf( array( 'cat_pages', 'cat_subcats', 'cat_files' ), isset($prop['size']) );
-               $this->addFieldsIf( 'cat_hidden', isset($prop['hidden']) );
+               if(isset($prop['hidden']))
+               {
+                       $this->addTables(array('page', 'page_props'));
+                       $this->addJoinConds(array(
+                               'page' => array('LEFT JOIN', array(
+                                       'page_namespace' => NS_CATEGORY,
+                                       'page_title=cat_title')),
+                               'page_props' => array('LEFT JOIN', array(
+                                       'pp_page=page_id',
+                                       'pp_propname' => 'hiddencat')),
+                       ));
+                       $this->addFields('pp_propname AS cat_hidden');
+               }
 
                $res = $this->select(__METHOD__);
 
index d495655..1b578b5 100644 (file)
@@ -55,8 +55,16 @@ class ApiQueryCategoryInfo extends ApiQueryBase {
                        $cattitles[$c] = $t->getDBKey();
                }
 
-               $this->addTables('category');
-               $this->addFields(array('cat_title', 'cat_pages', 'cat_subcats', 'cat_files', 'cat_hidden'));
+               $this->addTables(array('category', 'page', 'page_props'));
+               $this->addJoinConds(array(
+                       'page' => array('LEFT JOIN', array(
+                               'page_namespace' => NS_CATEGORY,
+                               'page_title=cat_title')),
+                       'page_props' => array('LEFT JOIN', array(
+                               'pp_page=page_id',
+                               'pp_propname' => 'hiddencat')),
+               ));
+               $this->addFields(array('cat_title', 'cat_pages', 'cat_subcats', 'cat_files', 'pp_propname AS cat_hidden'));
                $this->addWhere(array('cat_title' => $cattitles));                      
 
                $db = $this->getDB();