Index: trunk/phase3/includes/Interwiki.php |
— | — | @@ -32,25 +32,8 @@ |
33 | 33 | * @param $prefix string Interwiki prefix to use |
34 | 34 | */ |
35 | 35 | static public function isValidInterwiki( $prefix ){ |
36 | | - global $wgContLang; |
37 | | - $prefix = $wgContLang->lc( $prefix ); |
38 | | - if( isset( self::$smCache[$prefix] ) ){ |
39 | | - return true; |
40 | | - } |
41 | | - global $wgInterwikiCache; |
42 | | - if ($wgInterwikiCache) { |
43 | | - return Interwiki::isValidInterwikiCached( $key ); |
44 | | - } |
45 | | - $iw = Interwiki::load( $prefix ); |
46 | | - if( !$iw ){ |
47 | | - $iw = false; |
48 | | - } |
49 | | - if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){ |
50 | | - reset( self::$smCache ); |
51 | | - unset( self::$smCache[ key( self::$smCache ) ] ); |
52 | | - } |
53 | | - self::$smCache[$prefix] = $iw; |
54 | | - return ($iw != false); |
| 36 | + $result = self::fetch( $prefix ); |
| 37 | + return (bool)$result; |
55 | 38 | } |
56 | 39 | |
57 | 40 | /** |
— | — | @@ -61,6 +44,9 @@ |
62 | 45 | */ |
63 | 46 | static public function fetch( $prefix ) { |
64 | 47 | global $wgContLang; |
| 48 | + if( $prefix == '' ) { |
| 49 | + return null; |
| 50 | + } |
65 | 51 | $prefix = $wgContLang->lc( $prefix ); |
66 | 52 | if( isset( self::$smCache[$prefix] ) ){ |
67 | 53 | return self::$smCache[$prefix]; |
— | — | @@ -110,19 +96,6 @@ |
111 | 97 | } |
112 | 98 | |
113 | 99 | /** |
114 | | - * Check whether an interwiki is in the cache |
115 | | - * |
116 | | - * @note More logic is explained in DefaultSettings. |
117 | | - * |
118 | | - * @param $key \type{\string} Database key |
119 | | - * @return \type{\bool} Whether it exists |
120 | | - */ |
121 | | - protected static function isValidInterwikiCached( $key ) { |
122 | | - $value = getInterwikiCacheEntry( $key ); |
123 | | - return $value != ''; |
124 | | - } |
125 | | - |
126 | | - /** |
127 | 100 | * Get entry from interwiki cache |
128 | 101 | * |
129 | 102 | * @note More logic is explained in DefaultSettings. |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -675,7 +675,8 @@ |
676 | 676 | $query = wfArrayToCGI( $query ); |
677 | 677 | } |
678 | 678 | |
679 | | - if ( '' == $this->mInterwiki || !Interwiki::isValidInterwiki( $this->mInterwiki ) ) { |
| 679 | + $interwiki = Interwiki::fetch( $this->mInterwiki ); |
| 680 | + if ( !$interwiki ) { |
680 | 681 | $url = $this->getLocalUrl( $query, $variant ); |
681 | 682 | |
682 | 683 | // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc) |
— | — | @@ -684,7 +685,7 @@ |
685 | 686 | $url = $wgServer . $url; |
686 | 687 | } |
687 | 688 | } else { |
688 | | - $baseUrl = Interwiki::fetch( $this->mInterwiki )->getURL( ); |
| 689 | + $baseUrl = $interwiki->getURL( ); |
689 | 690 | |
690 | 691 | $namespace = wfUrlencode( $this->getNsText() ); |
691 | 692 | if ( '' != $namespace ) { |