From: Brad Jorsch Date: Mon, 29 Dec 2014 17:50:50 +0000 (-0500) Subject: API: Improve handling of interwiki redirects when resolving X-Git-Tag: 1.31.0-rc.0~12768^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=c515d0228f8b4c4cdef7ac40da3c70217cc61db9;p=lhc%2Fweb%2Fwiklou.git API: Improve handling of interwiki redirects when resolving When ApiPageSet resolves redirects, it should add the targets of any interwiki redirects to its list of interwiki titles. Also, when outputting the list of redirects it may as well include a 'tointerwiki' property to match the 'tofragment' property it already outputs. Bug: T85417 Change-Id: Icf1346f52c8efa099b502433de1b18c4caad09df --- diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index a217b4e6ef..faab69854e 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -173,6 +173,10 @@ production. for the 'aimime' parameter. * prop=info with inprop=protections will now return applicable protection types with the 'restrictiontypes' key. +* (T85417) When resolving redirects, ApiPageSet will now add the targets of + interwiki redirects to the list of interwiki titles. +* (T85417) When outputting the list of redirect titles, a 'tointerwiki' + property (like the existing 'tofragment' property) will be set. === Action API internal changes in 1.25 === * ApiHelp has been rewritten to support i18n and paginated HTML output. diff --git a/includes/api/ApiPageSet.php b/includes/api/ApiPageSet.php index 1417ef7833..e72383e5ce 100644 --- a/includes/api/ApiPageSet.php +++ b/includes/api/ApiPageSet.php @@ -450,6 +450,9 @@ class ApiPageSet extends ApiBase { if ( $titleTo->hasFragment() ) { $r['tofragment'] = $titleTo->getFragment(); } + if ( $titleTo->isExternal() ) { + $r['tointerwiki'] = $titleTo->getInterwiki(); + } $values[] = $r; } if ( !empty( $values ) && $result ) { @@ -1049,7 +1052,9 @@ class ApiPageSet extends ApiBase { $row->rd_interwiki ); unset( $this->mPendingRedirectIDs[$rdfrom] ); - if ( !$to->isExternal() && !isset( $this->mAllPages[$row->rd_namespace][$row->rd_title] ) ) { + if ( $to->isExternal() ) { + $this->mInterwikiTitles[$to->getPrefixedText()] = $to->getInterwiki(); + } elseif ( !isset( $this->mAllPages[$row->rd_namespace][$row->rd_title] ) ) { $lb->add( $row->rd_namespace, $row->rd_title ); } $this->mRedirectTitles[$from] = $to;