Followup r66872
authorSam Reed <reedy@users.mediawiki.org>
Tue, 25 May 2010 18:34:11 +0000 (18:34 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Tue, 25 May 2010 18:34:11 +0000 (18:34 +0000)
Use title to make interwiki

includes/api/ApiQueryIWLinks.php

index da664f3..7d13f07 100644 (file)
@@ -55,13 +55,6 @@ class ApiQueryIWLinks extends ApiQueryBase {
                $this->addTables( 'iwlinks' );
                $this->addWhereFld( 'iwl_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
 
-               $url = !is_null( $params['url'] );
-               if ( $url ) {
-                       $this->addTables( 'interwiki' );
-                       $this->addJoinConds( array( 'interwiki' => array( 'INNER JOIN', 'iw_prefix=iwl_prefix' ) ) );
-                       $this->addFields( 'iw_url' );
-               }
-
                if ( !is_null( $params['continue'] ) ) {
                        $cont = explode( '|', $params['continue'] );
                        if ( count( $cont ) != 3 ) {
@@ -100,9 +93,11 @@ class ApiQueryIWLinks extends ApiQueryBase {
                        }
                        $entry = array( 'prefix' => $row->iwl_prefix );
 
-                       if ( $url ) {
-                               $rowUrl = str_replace( '$1', $row->iwl_title, $row->iw_url );
-                               $entry = array_merge( $entry, array( 'url' => $rowUrl ) );
+                       if ( !is_null( $params['url'] ) ) {
+                               $title = Title::newFromText( "{$row->iwl_prefix}:{$row->iwl_title}" );
+                               if ( $title ) {
+                                       $entry = array_merge( $entry, array( 'url' => $title->getFullURL() ) );
+                               }
                        }
 
                        ApiResult::setContent( $entry, $row->iwl_title );