From: Roan Kattouw Date: Sat, 14 May 2011 12:48:07 +0000 (+0000) Subject: (bug 28952) Add tofragment to the redirect resolution info. X-Git-Tag: 1.31.0-rc.0~30210 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=4a072503722c477b4c5ad51c121645dc12ac3e75;p=lhc%2Fweb%2Fwiklou.git (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 --- diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index dc7ea95eab..fdee6fecd2 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -212,7 +212,7 @@ class ApiPageSet extends ApiQueryBase { /** * Get a list of redirect resolutions - maps a title to its redirect * target. - * @return array prefixed_title (string) => prefixed_title (string) + * @return array prefixed_title (string) => Title object */ public function getRedirectTitles() { return $this->mRedirectTitles; @@ -610,16 +610,17 @@ class ApiPageSet extends ApiQueryBase { array( 'rd_from', 'rd_namespace', + 'rd_fragment', + 'rd_interwiki', 'rd_title' ), array( 'rd_from' => array_keys( $this->mPendingRedirectIDs ) ), __METHOD__ ); $this->profileDBOut(); - foreach ( $res as $row ) { $rdfrom = intval( $row->rd_from ); $from = $this->mPendingRedirectIDs[$rdfrom]->getPrefixedText(); - $to = Title::makeTitle( $row->rd_namespace, $row->rd_title )->getPrefixedText(); + $to = Title::makeTitle( $row->rd_namespace, $row->rd_title, $row->rd_fragment, $row->rd_interwiki ); unset( $this->mPendingRedirectIDs[$rdfrom] ); if ( !isset( $this->mAllPages[$row->rd_namespace][$row->rd_title] ) ) { $lb->add( $row->rd_namespace, $row->rd_title ); @@ -638,7 +639,7 @@ class ApiPageSet extends ApiQueryBase { continue; } $lb->addObj( $rt ); - $this->mRedirectTitles[$title->getPrefixedText()] = $rt->getPrefixedText(); + $this->mRedirectTitles[$title->getPrefixedText()] = $rt; unset( $this->mPendingRedirectIDs[$id] ); } } diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 1292f75623..f62104104f 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -381,11 +381,15 @@ class ApiQuery extends ApiBase { // Show redirect information $redirValues = array(); - foreach ( $pageSet->getRedirectTitles() as $titleStrFrom => $titleStrTo ) { - $redirValues[] = array( + foreach ( $pageSet->getRedirectTitles() as $titleStrFrom => $titleTo ) { + $r = array( 'from' => strval( $titleStrFrom ), - 'to' => $titleStrTo + 'to' => $titleTo->getPrefixedText(), ); + if ( $titleTo->getFragment() !== '' ) { + $r['tofragment'] = $titleTo->getFragment(); + } + $redirValues[] = $r; } if ( count( $redirValues ) ) {