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 );
}
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 );
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
*
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;
}
}
}
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 )