From e9f4e3858797133e782d0248f10af5af1e0981e1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 1 Oct 2008 16:59:51 +0000 Subject: [PATCH] Reverting r41410 -- broke interwikis totally in parser tests. 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 | 44 +++++++++++++++++++++++++++--------------- includes/Linker.php | 9 --------- includes/Title.php | 2 +- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/includes/Interwiki.php b/includes/Interwiki.php index 754fb3b175..4c081ca6ab 100644 --- a/includes/Interwiki.php +++ b/includes/Interwiki.php @@ -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; } diff --git a/includes/Linker.php b/includes/Linker.php index 8bcdf7d0bd..dd899fec7b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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 ) diff --git a/includes/Title.php b/includes/Title.php index 9694f8884c..4fd382a12c 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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! -- 2.20.1