Reverting r41410 -- broke interwikis totally in parser tests.
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Oct 2008 16:59:51 +0000 (16:59 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 1 Oct 2008 16:59:51 +0000 (16:59 +0000)
   4 previously passing test(s) now FAILING! :(
      * Inline interwiki link  [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]
      * Inline interwiki link with empty title (bug 2372)  [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]
      * Interwiki link encoding conversion (bug 1636)  [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]
      * Interwiki link with fragment (bug 2130)  [Introduced between 30-Sep-2008 00:18:19, 1.14alpha (r41405) and 01-Oct-2008 16:31:38, 1.14alpha (r41504)]

includes/Interwiki.php
includes/Linker.php
includes/Title.php

index 754fb3b..4c081ca 100644 (file)
@@ -40,9 +40,7 @@ class Interwiki {
                        return Interwiki::getInterwikiCached( $key );
                }
                $iw = new Interwiki;
-               if(! $iw->load( $prefix ) ){
-                       return false;
-               }
+               $iw->load( $prefix );
                if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){
                        array_shift( self::$smCache );
                }
@@ -86,8 +84,6 @@ class Interwiki {
                        list( $local, $url ) = explode( ' ', $value, 2 );
                        $s->mURL = $url;
                        $s->mLocal = (int)$local;
-               }else{
-                       return false;
                }
                if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){
                        array_shift( self::$smCache );
@@ -96,6 +92,16 @@ class Interwiki {
                return $s;
        }
 
+       /**
+        * Clear all member variables in the current object. Does not clear
+        * the block from the DB.
+        */
+       function clear() {
+               $this->mURL = '';
+               $this->mLocal = $this->mTrans = 0;
+               $this->mPrefix = null;
+       }
+
        /**
         * Get the DB object
         *
@@ -117,19 +123,25 @@ class Interwiki {
                global $wgMemc;
                $key = wfMemcKey( 'interwiki', $prefix );
                $mc = $wgMemc->get( $key );
-               if( $mc && is_array( $mc ) && $this->loadFromArray( $mc ) ){ // is_array is hack for old keys
-                       wfDebug("Succeeded\n");
-                       return true;
+               if( $mc && is_array( $mc ) ){ // is_array is hack for old keys
+                       if( $this->loadFromArray( $mc ) ){
+                               wfDebug("Succeeded\n");
+                               return true;
+                       }
+               }else{
+                       $db =& $this->getDB();
+                       
+                       $res = $db->resultObject( $db->select( 'interwiki', '*', array( 'iw_prefix' => $prefix ),
+                               __METHOD__ ) );
+                       if ( $this->loadFromResult( $res ) ) {
+                               $mc = array( 'url' => $this->mURL, 'local' => $this->mLocal, 'trans' => $this->mTrans );
+                               $wgMemc->add( $key, $mc );
+                               return true;
+                       }
                }
                
-               $db =& $this->getDB();
-               $res = $db->resultObject( $db->select( 'interwiki', '*', array( 'iw_prefix' => $prefix ),
-                       __METHOD__ ) );
-               if ( $this->loadFromResult( $res ) ) {
-                       $mc = array( 'url' => $this->mURL, 'local' => $this->mLocal, 'trans' => $this->mTrans );
-                       $wgMemc->add( $key, $mc );
-                       return true;
-               }
+               # Give up
+               $this->clear();
                return false;
        }
 
index 8bcdf7d..dd899fe 100644 (file)
@@ -203,18 +203,9 @@ class Linker {
                        }
                }
                wfProfileOut( __METHOD__ . '-checkPageExistence' );
-               
-               $oldquery = array();
-               if( in_array( "forcearticlepath", $options ) && $query ){
-                       $oldquery = $query;
-                       $query = array();
-               }
 
                # Note: we want the href attribute first, for prettiness.
                $attribs = array( 'href' => $this->linkUrl( $target, $query, $options ) );
-               if( in_array( 'forcearticlepath', $options ) && $oldquery ){
-                       $attribs['href'] = wfAppendQuery( $attribs['href'], wfArrayToCgi( $oldquery ) );
-               }
                $attribs = array_merge(
                        $attribs,
                        $this->linkAttribs( $target, $customAttribs, $options )
index 9694f88..4fd382a 100644 (file)
@@ -2054,7 +2054,7 @@ class Title {
                                        # Ordinary namespace
                                        $dbkey = $m[2];
                                        $this->mNamespace = $ns;
-                               } elseif( Interwiki::fetch( $p ) ) {
+                               } elseif( new Interwiki( $p ) ) {
                                        if( !$firstPass ) {
                                                # Can't make a local interwiki link to an interwiki link.
                                                # That's just crazy!