* Add Linker::link flag for using article path
* Fix mistake in Interwiki-detecting code in Title * Clean up Interwiki.php per Tim's recommendations
This commit is contained in:
parent
110c0bb72f
commit
b368de47fd
3 changed files with 26 additions and 29 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 )
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
|
|
|||
Loading…
Reference in a new issue