API: Improve handling of interwiki redirects when resolving
authorBrad Jorsch <bjorsch@wikimedia.org>
Mon, 29 Dec 2014 17:50:50 +0000 (12:50 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 7 Jan 2015 20:49:35 +0000 (15:49 -0500)
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

RELEASE-NOTES-1.25
includes/api/ApiPageSet.php

index a217b4e..faab698 100644 (file)
@@ -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.
index 1417ef7..e72383e 100644 (file)
@@ -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;