From: Brad Jorsch Date: Wed, 2 Oct 2013 18:58:54 +0000 (-0400) Subject: API: Have action=parse indicate hidden categories X-Git-Tag: 1.31.0-rc.0~18293^2 X-Git-Url: https://git.heureux-cyclage.org/w/index.php?a=commitdiff_plain;h=b78b9131a86d791370592d20da818104b512e640;p=lhc%2Fweb%2Fwiklou.git API: Have action=parse indicate hidden categories Also whether the category page exists, since we can get that basically for free along with the 'hidden' flag. Bug: 54884 Change-Id: I5c435f04b1b3b65c4153dea1767d48b49ed427c2 --- diff --git a/RELEASE-NOTES-1.23 b/RELEASE-NOTES-1.23 index c9b56b9372..804ea43c00 100644 --- a/RELEASE-NOTES-1.23 +++ b/RELEASE-NOTES-1.23 @@ -26,6 +26,8 @@ production. acting as if the latest revision was being viewed. === API changes in 1.23 === +* (bug 54884) action=parse&prop=categories now indicates hidden and missing + categories. === Languages updated in 1.23=== diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index a369994b27..301affbc7d 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -461,12 +461,41 @@ class ApiParse extends ApiBase { private function formatCategoryLinks( $links ) { $result = array(); + + if ( !$links ) { + return $result; + } + + // Fetch hiddencat property + $lb = new LinkBatch; + $lb->setArray( array( NS_CATEGORY => $links ) ); + $db = $this->getDB(); + $res = $db->select( array( 'page', 'page_props' ), + array( 'page_title', 'pp_propname' ), + $lb->constructSet( 'page', $db ), + __METHOD__, + array(), + array( 'page_props' => array( + 'LEFT JOIN', array( 'pp_propname' => 'hiddencat', 'pp_page = page_id' ) + ) ) + ); + $hiddencats = array(); + foreach ( $res as $row ) { + $hiddencats[$row->page_title] = isset( $row->pp_propname ); + } + foreach ( $links as $link => $sortkey ) { $entry = array(); $entry['sortkey'] = $sortkey; ApiResult::setContent( $entry, $link ); + if ( !isset( $hiddencats[$link] ) ) { + $entry['missing'] = ''; + } elseif ( $hiddencats[$link] ) { + $entry['hidden'] = ''; + } $result[] = $entry; } + return $result; }