* @param $prefix string Interwiki prefix to use
*/
static public function isValidInterwiki( $prefix ){
- global $wgContLang;
- $prefix = $wgContLang->lc( $prefix );
- if( isset( self::$smCache[$prefix] ) ){
- return true;
- }
- global $wgInterwikiCache;
- if ($wgInterwikiCache) {
- return Interwiki::isValidInterwikiCached( $key );
- }
- $iw = Interwiki::load( $prefix );
- if( !$iw ){
- $iw = false;
- }
- if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){
- reset( self::$smCache );
- unset( self::$smCache[ key( self::$smCache ) ] );
- }
- self::$smCache[$prefix] = $iw;
- return ($iw != false);
+ $result = self::fetch( $prefix );
+ return (bool)$result;
}
/**
*/
static public function fetch( $prefix ) {
global $wgContLang;
+ if( $prefix == '' ) {
+ return null;
+ }
$prefix = $wgContLang->lc( $prefix );
if( isset( self::$smCache[$prefix] ) ){
return self::$smCache[$prefix];
return $s;
}
- /**
- * Check whether an interwiki is in the cache
- *
- * @note More logic is explained in DefaultSettings.
- *
- * @param $key \type{\string} Database key
- * @return \type{\bool} Whether it exists
- */
- protected static function isValidInterwikiCached( $key ) {
- $value = getInterwikiCacheEntry( $key );
- return $value != '';
- }
-
/**
* Get entry from interwiki cache
*
$query = wfArrayToCGI( $query );
}
- if ( '' == $this->mInterwiki || !Interwiki::isValidInterwiki( $this->mInterwiki ) ) {
+ $interwiki = Interwiki::fetch( $this->mInterwiki );
+ if ( !$interwiki ) {
$url = $this->getLocalUrl( $query, $variant );
// Ugly quick hack to avoid duplicate prefixes (bug 4571 etc)
$url = $wgServer . $url;
}
} else {
- $baseUrl = Interwiki::fetch( $this->mInterwiki )->getURL( );
+ $baseUrl = $interwiki->getURL( );
$namespace = wfUrlencode( $this->getNsText() );
if ( '' != $namespace ) {