From: Sam Reed Date: Thu, 22 Jul 2010 08:48:34 +0000 (+0000) Subject: (bug 23936) - Add "displaytitle" to query/info API X-Git-Tag: 1.31.0-rc.0~36016 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=65ae4eed55590d29a41d4f219c75de2090039c43;p=lhc%2Fweb%2Fwiklou.git (bug 23936) - Add "displaytitle" to query/info API Complete usage of accidental code from r69716 Move a $db = $this->getDB to after check in getTSIDs --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 516d3f5832..eb8213470a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -282,6 +282,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 24296) Added converttitles parameter to convert titles to their canonical language variant. * Fixed "link" parameter in image links with "thumb" parameter. +* (bug 23936) - Add "displaytitle" to query/info API === Languages updated in 1.17 === diff --git a/includes/api/ApiQueryInfo.php b/includes/api/ApiQueryInfo.php index f75b54e3d0..37557a4487 100644 --- a/includes/api/ApiQueryInfo.php +++ b/includes/api/ApiQueryInfo.php @@ -262,6 +262,10 @@ class ApiQueryInfo extends ApiQueryBase { if ( $this->fld_talkid || $this->fld_subjectid ) { $this->getTSIDs(); } + + if ( $this->fld_displaytitle ) { + $this->getDisplayTitle(); + } foreach ( $this->everything as $pageid => $title ) { $pageInfo = $this->extractPageInfo( $pageid, $title ); @@ -357,9 +361,13 @@ class ApiQueryInfo extends ApiQueryBase { } if ( $this->fld_displaytitle ) { - + if ( isset( $this->displaytitles[$title->getArticleId()] ) ) { + $pageInfo['displaytitle'] = $this->displaytitles[$title->getArticleId()]; + } else { + $pageInfo['displaytitle'] = $title; + } } - + return $pageInfo; } @@ -512,7 +520,7 @@ class ApiQueryInfo extends ApiQueryBase { */ private function getTSIDs() { $getTitles = $this->talkids = $this->subjectids = array(); - $db = $this->getDB(); + foreach ( $this->everything as $t ) { if ( MWNamespace::isTalk( $t->getNamespace() ) ) { if ( $this->fld_subjectid ) { @@ -525,6 +533,8 @@ class ApiQueryInfo extends ApiQueryBase { if ( !count( $getTitles ) ) { return; } + + $db = $this->getDB(); // Construct a custom WHERE clause that matches // all titles in $getTitles @@ -544,6 +554,31 @@ class ApiQueryInfo extends ApiQueryBase { } } } + + private function getDisplayTitle() { + $pageIds = $this->displaytitles = array(); + + foreach ( $this->everything as $t ) { + $pageIds = $t->getArticleID(); + } + + if ( !count( $pageIds ) ) { + return; + } + + $db = $this->getDB(); + + $this->resetQueryParams(); + $this->addTables( 'page_props' ); + $this->addFields( array( 'pp_page', 'pp_value' ) ); + $this->addWhereFld( 'pp_page', $pageIds ); + $this->addWhereFld( 'pp_propname', 'displaytitle' ); + $res = $this->select( __METHOD__ ); + + foreach ( $res as $row ) { + $this->displaytitles[$row->pp_page] = $row->pp_value; + } + } /** * Get information about watched status and put it in $this->watched @@ -589,7 +624,8 @@ class ApiQueryInfo extends ApiQueryBase { 'subjectid', 'url', 'readable', - 'preload' + 'preload', + 'displaytitle', ) ), 'token' => array( ApiBase::PARAM_DFLT => null,