Index: includes/api/ApiQueryCategoryMembers.php =================================================================== --- includes/api/ApiQueryCategoryMembers.php (revision 23171) +++ includes/api/ApiQueryCategoryMembers.php (working copy) @@ -63,6 +63,18 @@ $fld_title = isset($prop['title']); $fld_sortkey = isset($prop['sortkey']); + // First, let's check if anything redirects to this cat + $cats = array($categoryTitle->getDBkey()); + $db = $this->getDB(); + $this->addTables(array('page', 'redirect')); + $this->addFields('page_title'); + $this->addWhere('page_id = rd_from'); + $this->addWhereFld('rd_title', $categoryTitle->getDBkey()); + $res = $this->select(__METHOD__); + while($row = $db->fetchObject($res)) + $cats[] = $row->page_title; + $this->resetQueryParams(); + if (is_null($resultPageSet)) { $this->addFields(array('cl_sortkey', 'page_namespace', 'page_title')); $this->addFieldsIf('page_id', $fld_ids); @@ -76,15 +88,13 @@ $this->addWhere('cl_from=page_id'); $this->setContinuation($params['continue']); - $this->addWhereFld('cl_to', $categoryTitle->getDBkey()); + $this->addWhereFld('cl_to', $cats); $this->addWhereFld('page_namespace', $params['namespace']); $this->addOption('ORDER BY', "cl_to, cl_sortkey, cl_from"); $limit = $params['limit']; $this->addOption('LIMIT', $limit +1); - $db = $this->getDB(); - $data = array (); $count = 0; $lastSortKey = null;