r88060 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88059‎ | r88060 | r88061 >
Date:12:48, 14 May 2011
Author:catrope
Status:ok
Tags:
Comment:
(bug 28952) Add tofragment to the redirect resolution info.

Changes the format of ApiPageSet::getRedirectTitles() from returning prefixed text strings to returning title objects so we can obtain the fragment info
Modified paths:
  • /trunk/phase3/includes/api/ApiPageSet.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQuery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuery.php
@@ -381,11 +381,15 @@
382382
383383 // Show redirect information
384384 $redirValues = array();
385 - foreach ( $pageSet->getRedirectTitles() as $titleStrFrom => $titleStrTo ) {
386 - $redirValues[] = array(
 385+ foreach ( $pageSet->getRedirectTitles() as $titleStrFrom => $titleTo ) {
 386+ $r = array(
387387 'from' => strval( $titleStrFrom ),
388 - 'to' => $titleStrTo
 388+ 'to' => $titleTo->getPrefixedText(),
389389 );
 390+ if ( $titleTo->getFragment() !== '' ) {
 391+ $r['tofragment'] = $titleTo->getFragment();
 392+ }
 393+ $redirValues[] = $r;
390394 }
391395
392396 if ( count( $redirValues ) ) {
Index: trunk/phase3/includes/api/ApiPageSet.php
@@ -212,7 +212,7 @@
213213 /**
214214 * Get a list of redirect resolutions - maps a title to its redirect
215215 * target.
216 - * @return array prefixed_title (string) => prefixed_title (string)
 216+ * @return array prefixed_title (string) => Title object
217217 */
218218 public function getRedirectTitles() {
219219 return $this->mRedirectTitles;
@@ -610,16 +610,17 @@
611611 array(
612612 'rd_from',
613613 'rd_namespace',
 614+ 'rd_fragment',
 615+ 'rd_interwiki',
614616 'rd_title'
615617 ), array( 'rd_from' => array_keys( $this->mPendingRedirectIDs ) ),
616618 __METHOD__
617619 );
618620 $this->profileDBOut();
619 -
620621 foreach ( $res as $row ) {
621622 $rdfrom = intval( $row->rd_from );
622623 $from = $this->mPendingRedirectIDs[$rdfrom]->getPrefixedText();
623 - $to = Title::makeTitle( $row->rd_namespace, $row->rd_title )->getPrefixedText();
 624+ $to = Title::makeTitle( $row->rd_namespace, $row->rd_title, $row->rd_fragment, $row->rd_interwiki );
624625 unset( $this->mPendingRedirectIDs[$rdfrom] );
625626 if ( !isset( $this->mAllPages[$row->rd_namespace][$row->rd_title] ) ) {
626627 $lb->add( $row->rd_namespace, $row->rd_title );
@@ -638,7 +639,7 @@
639640 continue;
640641 }
641642 $lb->addObj( $rt );
642 - $this->mRedirectTitles[$title->getPrefixedText()] = $rt->getPrefixedText();
 643+ $this->mRedirectTitles[$title->getPrefixedText()] = $rt;
643644 unset( $this->mPendingRedirectIDs[$id] );
644645 }
645646 }

Status & tagging log