Index: trunk/phase3/includes/Interwiki.php |
— | — | @@ -53,12 +53,13 @@ |
54 | 54 | } |
55 | 55 | global $wgInterwikiCache; |
56 | 56 | if ($wgInterwikiCache) { |
57 | | - return Interwiki::getInterwikiCached( $key ); |
| 57 | + $iw = Interwiki::getInterwikiCached( $prefix ); |
| 58 | + } else { |
| 59 | + $iw = Interwiki::load( $prefix ); |
| 60 | + if( !$iw ){ |
| 61 | + $iw = false; |
| 62 | + } |
58 | 63 | } |
59 | | - $iw = Interwiki::load( $prefix ); |
60 | | - if( !$iw ){ |
61 | | - $iw = false; |
62 | | - } |
63 | 64 | if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){ |
64 | 65 | reset( self::$smCache ); |
65 | 66 | unset( self::$smCache[ key( self::$smCache ) ] ); |
— | — | @@ -72,13 +73,13 @@ |
73 | 74 | * |
74 | 75 | * @note More logic is explained in DefaultSettings. |
75 | 76 | * |
76 | | - * @param $key \type{\string} Database key |
| 77 | + * @param $prefix \type{\string} Interwiki prefix |
77 | 78 | * @return \type{\Interwiki} An interwiki object |
78 | 79 | */ |
79 | | - protected static function getInterwikiCached( $key ) { |
80 | | - $value = self::getInterwikiCacheEntry( $key ); |
| 80 | + protected static function getInterwikiCached( $prefix ) { |
| 81 | + $value = self::getInterwikiCacheEntry( $prefix ); |
81 | 82 | |
82 | | - $s = new Interwiki( $key ); |
| 83 | + $s = new Interwiki( $prefix ); |
83 | 84 | if ( $value != '' ) { |
84 | 85 | // Split values |
85 | 86 | list( $local, $url ) = explode( ' ', $value, 2 ); |
— | — | @@ -87,11 +88,6 @@ |
88 | 89 | }else{ |
89 | 90 | $s = false; |
90 | 91 | } |
91 | | - if( self::CACHE_LIMIT && count( self::$smCache ) >= self::CACHE_LIMIT ){ |
92 | | - reset( self::$smCache ); |
93 | | - unset( self::$smCache[ key( self::$smCache ) ] ); |
94 | | - } |
95 | | - self::$smCache[$prefix] = $s; |
96 | 92 | return $s; |
97 | 93 | } |
98 | 94 | |
— | — | @@ -100,13 +96,14 @@ |
101 | 97 | * |
102 | 98 | * @note More logic is explained in DefaultSettings. |
103 | 99 | * |
104 | | - * @param $key \type{\string} Database key |
| 100 | + * @param $prefix \type{\string} Database key |
105 | 101 | * @return \type{\string) The entry |
106 | 102 | */ |
107 | | - protected static function getInterwikiCacheEntry( $key ){ |
| 103 | + protected static function getInterwikiCacheEntry( $prefix ){ |
108 | 104 | global $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite; |
109 | 105 | static $db, $site; |
110 | 106 | |
| 107 | + wfDebug( __METHOD__ . "( $prefix )\n" ); |
111 | 108 | if( !$db ){ |
112 | 109 | $db = dba_open( $wgInterwikiCache, 'r', 'cdb' ); |
113 | 110 | } |
— | — | @@ -118,14 +115,14 @@ |
119 | 116 | } |
120 | 117 | } |
121 | 118 | |
122 | | - $value = dba_fetch( wfMemcKey( $key ), $db ); |
| 119 | + $value = dba_fetch( wfMemcKey( $prefix ), $db ); |
123 | 120 | // Site level |
124 | 121 | if ( $value == '' && $wgInterwikiScopes >= 3 ) { |
125 | | - $value = dba_fetch( "_{$site}:{$key}", $db ); |
| 122 | + $value = dba_fetch( "_{$site}:{$prefix}", $db ); |
126 | 123 | } |
127 | 124 | // Global Level |
128 | 125 | if ( $value == '' && $wgInterwikiScopes >= 2 ) { |
129 | | - $value = dba_fetch( "__global:{$key}", $db ); |
| 126 | + $value = dba_fetch( "__global:{$prefix}", $db ); |
130 | 127 | } |
131 | 128 | if ( $value == 'undef' ) |
132 | 129 | $value = ''; |