return $this->$name;
}
+ function getWikiID() {
+ if( $this->mTablePrefix ) {
+ return "{$this->mDBname}-{$this->mTablePrefix}";
+ } else {
+ return $this->mDBname;
+ }
+ }
+
#------------------------------------------------------------------------------
# Other functions
#------------------------------------------------------------------------------
* Get a cache key
*/
function wfMemcKey( /*... */ ) {
- global $wgDBprefix, $wgDBname;
$args = func_get_args();
- if ( $wgDBprefix ) {
- $key = "$wgDBname-$wgDBprefix:" . implode( ':', $args );
- } else {
- $key = $wgDBname . ':' . implode( ':', $args );
- }
+ $key = wfWikiID() . ':' . implode( ':', $args );
return $key;
}
* Get an ASCII string identifying this wiki
* This is used as a prefix in memcached keys
*/
-function wfWikiID() {
- global $wgDBprefix, $wgDBname;
- if ( $wgDBprefix ) {
- return "$wgDBname-$wgDBprefix";
+function wfWikiID( $db = null ) {
+ if( $db instanceof Database ) {
+ return $db->getWikiID();
} else {
- return $wgDBname;
+ global $wgDBprefix, $wgDBname;
+ if ( $wgDBprefix ) {
+ return "$wgDBname-$wgDBprefix";
+ } else {
+ return $wgDBname;
+ }
}
}
/**
* Bump this number when serialized cache records may be incompatible.
*/
-define( 'MW_FILE_VERSION', 7 );
+define( 'MW_FILE_VERSION', 8 );
/**
* Class to represent a local file in the wiki's own database
return wfGetDB( DB_MASTER );
}
+ function getMemcKey( $key ) {
+ return wfWikiID( $this->getSlaveDB() ) . ":{$key}";
+ }
+
function newFileFromRow( $row ) {
if ( isset( $row->img_name ) ) {
return LocalFile::newFromRow( $row, $this );
$title = Title::makeTitle( NS_IMAGE, $title->getText() );
}
- $memcKey = wfMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
+ $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
$cachedValue = $wgMemc->get( $memcKey );
if( $cachedValue ) {
return Title::newFromDbKey( $cachedValue );
function invalidateImageRedirect( $title ) {
global $wgMemc;
- $memcKey = wfMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
+ $memcKey = $this->getMemcKey( "image_redirect:" . md5( $title->getPrefixedDBkey() ) );
$wgMemc->delete( $memcKey );
}
}