* Don't connect to the commons DB on cache hits, in order to determine the cache key name. Removed remnants of that bright idea from GlobalFunctions.php. * Fixed total failure of negative caching in checkRedirect() due to memcached stripping trailing spaces from string values. Probably never worked. Also: * Respect hasSharedCache in foreign repos. Recently-added code was apparently ignorant of this setting. * Renamed getMemcKey() to getSharedCacheKey() to make its function more clear, introduced getLocalCacheKey() to do the other thing. Fixed its parameters to be like wfMemcKey() and used it in more places. * Used getLocalCacheKey() in various places instead of wfMemc(), to avoid having multiple repositories overwrite each others' caches. * Fixed the BagOStuff bug that the FIXME in LocalRepo::checkRedirect() appears to refer to. * Removed getMasterDB() and getSlaveDB() from FileRepo, it's incorrect to assume that a repo other than a LocalRepo has an associated database. * Made FileRepo::invalidateImageRedirect() a stub, to match FileRepo::checkRedirect(). Moved the functionality to LocalRepo where checkRedirect() is concretely implemented.
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* A foreign repository with a MediaWiki database accessible via the configured LBFactory
|
|
* @ingroup FileRepo
|
|
*/
|
|
class ForeignDBViaLBRepo extends LocalRepo {
|
|
var $wiki, $dbName, $tablePrefix;
|
|
var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
|
|
var $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
|
|
|
|
function __construct( $info ) {
|
|
parent::__construct( $info );
|
|
$this->wiki = $info['wiki'];
|
|
list( $this->dbName, $this->tablePrefix ) = wfSplitWikiID( $this->wiki );
|
|
$this->hasSharedCache = $info['hasSharedCache'];
|
|
}
|
|
|
|
function getMasterDB() {
|
|
return wfGetDB( DB_MASTER, array(), $this->wiki );
|
|
}
|
|
|
|
function getSlaveDB() {
|
|
return wfGetDB( DB_SLAVE, array(), $this->wiki );
|
|
}
|
|
function hasSharedCache() {
|
|
return $this->hasSharedCache;
|
|
}
|
|
|
|
/**
|
|
* Get a key on the primary cache for this repository.
|
|
* Returns false if the repository's cache is not accessible at this site.
|
|
* The parameters are the parts of the key, as for wfMemcKey().
|
|
*/
|
|
function getSharedCacheKey( /*...*/ ) {
|
|
if ( $this->hasSharedCache() ) {
|
|
$args = func_get_args();
|
|
array_unshift( $args, $this->wiki );
|
|
return implode( ':', $args );
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function store( $srcPath, $dstZone, $dstRel, $flags = 0 ) {
|
|
throw new MWException( get_class($this) . ': write operations are not supported' );
|
|
}
|
|
function publish( $srcPath, $dstRel, $archiveRel, $flags = 0 ) {
|
|
throw new MWException( get_class($this) . ': write operations are not supported' );
|
|
}
|
|
function deleteBatch( $fileMap ) {
|
|
throw new MWException( get_class($this) . ': write operations are not supported' );
|
|
}
|
|
}
|