Revert changes to SpecialSearch.php in r70608 because Special:Search didn't load...
[lhc/web/wiklou.git] / includes / api / ApiQueryIWLinks.php
index da664f3..90eb751 100644 (file)
@@ -20,7 +20,7 @@
  *
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
  */
 
@@ -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 ) {
@@ -90,8 +83,7 @@ class ApiQueryIWLinks extends ApiQueryBase {
                $res = $this->select( __METHOD__ );
 
                $count = 0;
-               $db = $this->getDB();
-               while ( $row = $db->fetchObject( $res ) ) {
+               foreach ( $res as $row ) {
                        if ( ++$count > $params['limit'] ) {
                                // We've reached the one extra which shows that
                                // there are additional pages to be had. Stop here...
@@ -100,9 +92,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 );
@@ -112,7 +106,10 @@ class ApiQueryIWLinks extends ApiQueryBase {
                                break;
                        }
                }
-               $db->freeResult( $res );
+       }
+
+       public function getCacheMode( $params ) {
+               return 'public';
        }
 
        public function getAllowedParams() {
@@ -157,4 +154,4 @@ class ApiQueryIWLinks extends ApiQueryBase {
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }
-}
\ No newline at end of file
+}