r69719 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69718‎ | r69719 | r69720 >
Date:08:48, 22 July 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
(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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryInfo.php
@@ -262,6 +262,10 @@
263263 if ( $this->fld_talkid || $this->fld_subjectid ) {
264264 $this->getTSIDs();
265265 }
 266+
 267+ if ( $this->fld_displaytitle ) {
 268+ $this->getDisplayTitle();
 269+ }
266270
267271 foreach ( $this->everything as $pageid => $title ) {
268272 $pageInfo = $this->extractPageInfo( $pageid, $title );
@@ -357,9 +361,13 @@
358362 }
359363
360364 if ( $this->fld_displaytitle ) {
361 -
 365+ if ( isset( $this->displaytitles[$title->getArticleId()] ) ) {
 366+ $pageInfo['displaytitle'] = $this->displaytitles[$title->getArticleId()];
 367+ } else {
 368+ $pageInfo['displaytitle'] = $title;
 369+ }
362370 }
363 -
 371+
364372 return $pageInfo;
365373 }
366374
@@ -512,7 +520,7 @@
513521 */
514522 private function getTSIDs() {
515523 $getTitles = $this->talkids = $this->subjectids = array();
516 - $db = $this->getDB();
 524+
517525 foreach ( $this->everything as $t ) {
518526 if ( MWNamespace::isTalk( $t->getNamespace() ) ) {
519527 if ( $this->fld_subjectid ) {
@@ -525,6 +533,8 @@
526534 if ( !count( $getTitles ) ) {
527535 return;
528536 }
 537+
 538+ $db = $this->getDB();
529539
530540 // Construct a custom WHERE clause that matches
531541 // all titles in $getTitles
@@ -544,7 +554,32 @@
545555 }
546556 }
547557 }
 558+
 559+ private function getDisplayTitle() {
 560+ $pageIds = $this->displaytitles = array();
 561+
 562+ foreach ( $this->everything as $t ) {
 563+ $pageIds = $t->getArticleID();
 564+ }
 565+
 566+ if ( !count( $pageIds ) ) {
 567+ return;
 568+ }
 569+
 570+ $db = $this->getDB();
548571
 572+ $this->resetQueryParams();
 573+ $this->addTables( 'page_props' );
 574+ $this->addFields( array( 'pp_page', 'pp_value' ) );
 575+ $this->addWhereFld( 'pp_page', $pageIds );
 576+ $this->addWhereFld( 'pp_propname', 'displaytitle' );
 577+ $res = $this->select( __METHOD__ );
 578+
 579+ foreach ( $res as $row ) {
 580+ $this->displaytitles[$row->pp_page] = $row->pp_value;
 581+ }
 582+ }
 583+
549584 /**
550585 * Get information about watched status and put it in $this->watched
551586 */
@@ -589,7 +624,8 @@
590625 'subjectid',
591626 'url',
592627 'readable',
593 - 'preload'
 628+ 'preload',
 629+ 'displaytitle',
594630 ) ),
595631 'token' => array(
596632 ApiBase::PARAM_DFLT => null,
Index: trunk/phase3/RELEASE-NOTES
@@ -282,6 +282,7 @@
283283 * (bug 24296) Added converttitles parameter to convert titles to their
284284 canonical language variant.
285285 * Fixed "link" parameter in image links with "thumb" parameter.
 286+* (bug 23936) - Add "displaytitle" to query/info API
286287
287288 === Languages updated in 1.17 ===
288289

Follow-up revisions

RevisionCommit summaryAuthorDate
r69722Followup r69719 r66716, add variable definition to false...reedy09:47, 22 July 2010
r69724Fixup r69719 per commentsreedy10:18, 22 July 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69716Fix bug from r61759...reedy07:00, 22 July 2010

Comments

#Comment by Catrope (talk | contribs)   10:11, 22 July 2010
+				$pageInfo['displaytitle'] = $title;

Should be $title->getPrefixedText() for those PHP versions that don't to magic __toString() properly.

+		foreach ( $this->everything as $t ) {
+			$pageIds = $t->getArticleID();
+		}

Simply $pageIds = array_keys( $this->titles ); will do. $this->everything contains missing titles as well, and those sure don't have a displaytitle.

Status & tagging log