From: Matt Johnston Date: Tue, 30 Sep 2008 01:56:54 +0000 (+0000) Subject: * Add Linker::link flag for using article path X-Git-Tag: 1.31.0-rc.0~45000 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=b368de47fd41d0ef37aeb765f7d71c13feae7c33;p=lhc%2Fweb%2Fwiklou.git * Add Linker::link flag for using article path * Fix mistake in Interwiki-detecting code in Title * Clean up Interwiki.php per Tim's recommendations --- diff --git a/includes/Interwiki.php b/includes/Interwiki.php index 4c081ca6ab..754fb3b175 100644 --- a/includes/Interwiki.php +++ b/includes/Interwiki.php @@ -40,7 +40,9 @@ class Interwiki { return Interwiki::getInterwikiCached( $key ); } $iw = new Interwiki; - $iw->load( $prefix ); + if(! $iw->load( $prefix ) ){ + return false; + } if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){ array_shift( self::$smCache ); } @@ -84,6 +86,8 @@ 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 ); @@ -92,16 +96,6 @@ 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 * @@ -123,25 +117,19 @@ class Interwiki { global $wgMemc; $key = wfMemcKey( 'interwiki', $prefix ); $mc = $wgMemc->get( $key ); - 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; - } + if( $mc && is_array( $mc ) && $this->loadFromArray( $mc ) ){ // is_array is hack for old keys + wfDebug("Succeeded\n"); + return true; } - # Give up - $this->clear(); + $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; + } return false; } diff --git a/includes/Linker.php b/includes/Linker.php index dd899fec7b..8bcdf7d0bd 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -203,9 +203,18 @@ 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 10a61683da..c8de709da3 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2054,7 +2054,7 @@ class Title { # Ordinary namespace $dbkey = $m[2]; $this->mNamespace = $ns; - } elseif( new Interwiki( $p ) ) { + } elseif( Interwiki::fetch( $p ) ) { if( !$firstPass ) { # Can't make a local interwiki link to an interwiki link. # That's just crazy!