Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -2337,13 +2337,8 @@ |
2338 | 2338 | * Get a cache key |
2339 | 2339 | */ |
2340 | 2340 | function wfMemcKey( /*... */ ) { |
2341 | | - global $wgDBprefix, $wgDBname; |
2342 | 2341 | $args = func_get_args(); |
2343 | | - if ( $wgDBprefix ) { |
2344 | | - $key = "$wgDBname-$wgDBprefix:" . implode( ':', $args ); |
2345 | | - } else { |
2346 | | - $key = $wgDBname . ':' . implode( ':', $args ); |
2347 | | - } |
| 2342 | + $key = wfWikiID() . ':' . implode( ':', $args ); |
2348 | 2343 | return $key; |
2349 | 2344 | } |
2350 | 2345 | |
— | — | @@ -2364,12 +2359,16 @@ |
2365 | 2360 | * Get an ASCII string identifying this wiki |
2366 | 2361 | * This is used as a prefix in memcached keys |
2367 | 2362 | */ |
2368 | | -function wfWikiID() { |
2369 | | - global $wgDBprefix, $wgDBname; |
2370 | | - if ( $wgDBprefix ) { |
2371 | | - return "$wgDBname-$wgDBprefix"; |
| 2363 | +function wfWikiID( $db = null ) { |
| 2364 | + if( $db instanceof Database ) { |
| 2365 | + return $db->getWikiID(); |
2372 | 2366 | } else { |
2373 | | - return $wgDBname; |
| 2367 | + global $wgDBprefix, $wgDBname; |
| 2368 | + if ( $wgDBprefix ) { |
| 2369 | + return "$wgDBname-$wgDBprefix"; |
| 2370 | + } else { |
| 2371 | + return $wgDBname; |
| 2372 | + } |
2374 | 2373 | } |
2375 | 2374 | } |
2376 | 2375 | |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | /** |
7 | 7 | * Bump this number when serialized cache records may be incompatible. |
8 | 8 | */ |
9 | | -define( 'MW_FILE_VERSION', 7 ); |
| 9 | +define( 'MW_FILE_VERSION', 8 ); |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Class to represent a local file in the wiki's own database |
Index: trunk/phase3/includes/filerepo/LocalRepo.php |
— | — | @@ -15,6 +15,10 @@ |
16 | 16 | return wfGetDB( DB_MASTER ); |
17 | 17 | } |
18 | 18 | |
| 19 | + function getMemcKey( $key ) { |
| 20 | + return wfWikiID( $this->getSlaveDB() ) . ":{$key}"; |
| 21 | + } |
| 22 | + |
19 | 23 | function newFileFromRow( $row ) { |
20 | 24 | if ( isset( $row->img_name ) ) { |
21 | 25 | return LocalFile::newFromRow( $row, $this ); |
— | — | @@ -104,7 +108,7 @@ |
105 | 109 | $title = Title::makeTitle( NS_IMAGE, $title->getText() ); |
106 | 110 | } |
107 | 111 | |
108 | | - $memcKey = wfMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) ); |
| 112 | + $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) ); |
109 | 113 | $cachedValue = $wgMemc->get( $memcKey ); |
110 | 114 | if( $cachedValue ) { |
111 | 115 | return Title::newFromDbKey( $cachedValue ); |
— | — | @@ -135,7 +139,7 @@ |
136 | 140 | |
137 | 141 | function invalidateImageRedirect( $title ) { |
138 | 142 | global $wgMemc; |
139 | | - $memcKey = wfMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) ); |
| 143 | + $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) ); |
140 | 144 | $wgMemc->delete( $memcKey ); |
141 | 145 | } |
142 | 146 | } |
Index: trunk/phase3/includes/Database.php |
— | — | @@ -226,6 +226,14 @@ |
227 | 227 | return $this->$name; |
228 | 228 | } |
229 | 229 | |
| 230 | + function getWikiID() { |
| 231 | + if( $this->mTablePrefix ) { |
| 232 | + return "{$this->mDBname}-{$this->mTablePrefix}"; |
| 233 | + } else { |
| 234 | + return $this->mDBname; |
| 235 | + } |
| 236 | + } |
| 237 | + |
230 | 238 | #------------------------------------------------------------------------------ |
231 | 239 | # Other functions |
232 | 240 | #------------------------------------------------------------------------------ |