Rename getSlaveDB() FileRepo method to getReplicaDB()
The old name is left as an alias. Change-Id: I60ab2cd5ce05df4247d5e25b017d2debee56554e
This commit is contained in:
parent
ad86dda42f
commit
f525c72590
13 changed files with 40 additions and 30 deletions
|
|
@ -44,10 +44,10 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
|
|||
* which may not necessarily be the same as the local DB.
|
||||
*
|
||||
* TODO: allow querying non-local repos.
|
||||
* @return Database
|
||||
* @return IDatabase
|
||||
*/
|
||||
protected function getDB() {
|
||||
return $this->mRepo->getSlaveDB();
|
||||
return $this->mRepo->getReplicaDB();
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class ForeignDBRepo extends LocalRepo {
|
|||
/**
|
||||
* @return IDatabase
|
||||
*/
|
||||
function getSlaveDB() {
|
||||
function getReplicaDB() {
|
||||
return $this->getMasterDB();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class ForeignDBViaLBRepo extends LocalRepo {
|
|||
/**
|
||||
* @return IDatabase
|
||||
*/
|
||||
function getSlaveDB() {
|
||||
function getReplicaDB() {
|
||||
return wfGetLB( $this->wiki )->getConnectionRef( DB_REPLICA, [], $this->wiki );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class LocalRepo extends FileRepo {
|
|||
$memcKey,
|
||||
$expiry,
|
||||
function ( $oldValue, &$ttl, array &$setOpts ) use ( $method, $title ) {
|
||||
$dbr = $this->getSlaveDB(); // possibly remote DB
|
||||
$dbr = $this->getReplicaDB(); // possibly remote DB
|
||||
|
||||
$setOpts += Database::getCacheSetOptions( $dbr );
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ class LocalRepo extends FileRepo {
|
|||
}
|
||||
};
|
||||
|
||||
$dbr = $this->getSlaveDB();
|
||||
$dbr = $this->getReplicaDB();
|
||||
|
||||
// Query image table
|
||||
$imgNames = [];
|
||||
|
|
@ -368,7 +368,7 @@ class LocalRepo extends FileRepo {
|
|||
* @return File[]
|
||||
*/
|
||||
function findBySha1( $hash ) {
|
||||
$dbr = $this->getSlaveDB();
|
||||
$dbr = $this->getReplicaDB();
|
||||
$res = $dbr->select(
|
||||
'image',
|
||||
LocalFile::selectFields(),
|
||||
|
|
@ -400,7 +400,7 @@ class LocalRepo extends FileRepo {
|
|||
return []; // empty parameter
|
||||
}
|
||||
|
||||
$dbr = $this->getSlaveDB();
|
||||
$dbr = $this->getReplicaDB();
|
||||
$res = $dbr->select(
|
||||
'image',
|
||||
LocalFile::selectFields(),
|
||||
|
|
@ -430,7 +430,7 @@ class LocalRepo extends FileRepo {
|
|||
$selectOptions = [ 'ORDER BY' => 'img_name', 'LIMIT' => intval( $limit ) ];
|
||||
|
||||
// Query database
|
||||
$dbr = $this->getSlaveDB();
|
||||
$dbr = $this->getReplicaDB();
|
||||
$res = $dbr->select(
|
||||
'image',
|
||||
LocalFile::selectFields(),
|
||||
|
|
@ -452,10 +452,20 @@ class LocalRepo extends FileRepo {
|
|||
* Get a connection to the replica DB
|
||||
* @return IDatabase
|
||||
*/
|
||||
function getSlaveDB() {
|
||||
function getReplicaDB() {
|
||||
return wfGetDB( DB_REPLICA );
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for getReplicaDB()
|
||||
*
|
||||
* @return IDatabase
|
||||
* @deprecated Since 1.29
|
||||
*/
|
||||
function getSlaveDB() {
|
||||
return $this->getReplicaDB();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a connection to the master DB
|
||||
* @return IDatabase
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ class ForeignDBFile extends LocalFile {
|
|||
return false;
|
||||
}
|
||||
|
||||
$touched = $this->repo->getSlaveDB()->selectField(
|
||||
$touched = $this->repo->getReplicaDB()->selectField(
|
||||
'page',
|
||||
'page_touched',
|
||||
[
|
||||
|
|
@ -179,7 +179,7 @@ class ForeignDBFile extends LocalFile {
|
|||
* @since 1.27
|
||||
*/
|
||||
public function getDescriptionShortUrl() {
|
||||
$dbr = $this->repo->getSlaveDB();
|
||||
$dbr = $this->repo->getReplicaDB();
|
||||
$pageId = $dbr->selectField(
|
||||
'page',
|
||||
'page_id',
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class LocalFile extends File {
|
|||
* @return bool|LocalFile
|
||||
*/
|
||||
static function newFromKey( $sha1, $repo, $timestamp = false ) {
|
||||
$dbr = $repo->getSlaveDB();
|
||||
$dbr = $repo->getReplicaDB();
|
||||
|
||||
$conds = [ 'img_sha1' => $sha1 ];
|
||||
if ( $timestamp ) {
|
||||
|
|
@ -259,7 +259,7 @@ class LocalFile extends File {
|
|||
$key,
|
||||
$cache::TTL_WEEK,
|
||||
function ( $oldValue, &$ttl, array &$setOpts ) use ( $cache ) {
|
||||
$setOpts += Database::getCacheSetOptions( $this->repo->getSlaveDB() );
|
||||
$setOpts += Database::getCacheSetOptions( $this->repo->getReplicaDB() );
|
||||
|
||||
$this->loadFromDB( self::READ_NORMAL );
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ class LocalFile extends File {
|
|||
|
||||
$dbr = ( $flags & self::READ_LATEST )
|
||||
? $this->repo->getMasterDB()
|
||||
: $this->repo->getSlaveDB();
|
||||
: $this->repo->getReplicaDB();
|
||||
|
||||
$row = $dbr->selectRow( 'image', $this->getCacheFields( 'img_' ),
|
||||
[ 'img_name' => $this->getName() ], $fname );
|
||||
|
|
@ -412,7 +412,7 @@ class LocalFile extends File {
|
|||
# Unconditionally set loaded=true, we don't want the accessors constantly rechecking
|
||||
$this->extraDataLoaded = true;
|
||||
|
||||
$fieldMap = $this->loadFieldsWithTimestamp( $this->repo->getSlaveDB(), $fname );
|
||||
$fieldMap = $this->loadFieldsWithTimestamp( $this->repo->getReplicaDB(), $fname );
|
||||
if ( !$fieldMap ) {
|
||||
$fieldMap = $this->loadFieldsWithTimestamp( $this->repo->getMasterDB(), $fname );
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ class LocalFile extends File {
|
|||
|
||||
$decoded['timestamp'] = wfTimestamp( TS_MW, $decoded['timestamp'] );
|
||||
|
||||
$decoded['metadata'] = $this->repo->getSlaveDB()->decodeBlob( $decoded['metadata'] );
|
||||
$decoded['metadata'] = $this->repo->getReplicaDB()->decodeBlob( $decoded['metadata'] );
|
||||
|
||||
if ( empty( $decoded['major_mime'] ) ) {
|
||||
$decoded['mime'] = 'unknown/unknown';
|
||||
|
|
@ -1037,7 +1037,7 @@ class LocalFile extends File {
|
|||
* @return OldLocalFile[]
|
||||
*/
|
||||
function getHistory( $limit = null, $start = null, $end = null, $inc = true ) {
|
||||
$dbr = $this->repo->getSlaveDB();
|
||||
$dbr = $this->repo->getReplicaDB();
|
||||
$tables = [ 'oldimage' ];
|
||||
$fields = OldLocalFile::selectFields();
|
||||
$conds = $opts = $join_conds = [];
|
||||
|
|
@ -1091,7 +1091,7 @@ class LocalFile extends File {
|
|||
# Polymorphic function name to distinguish foreign and local fetches
|
||||
$fname = get_class( $this ) . '::' . __FUNCTION__;
|
||||
|
||||
$dbr = $this->repo->getSlaveDB();
|
||||
$dbr = $this->repo->getReplicaDB();
|
||||
|
||||
if ( $this->historyLine == 0 ) { // called for the first time, return line from cur
|
||||
$this->historyRes = $dbr->select( 'image',
|
||||
|
|
@ -1917,7 +1917,7 @@ class LocalFile extends File {
|
|||
'page_namespace' => $this->title->getNamespace(),
|
||||
'page_title' => $this->title->getDBkey()
|
||||
];
|
||||
$touched = $this->repo->getSlaveDB()->selectField( 'page', 'page_touched', $cond, __METHOD__ );
|
||||
$touched = $this->repo->getReplicaDB()->selectField( 'page', 'page_touched', $cond, __METHOD__ );
|
||||
$this->descriptionTouched = $touched ? wfTimestamp( TS_MW, $touched ) : false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class OldLocalFile extends LocalFile {
|
|||
* @return bool|OldLocalFile
|
||||
*/
|
||||
static function newFromKey( $sha1, $repo, $timestamp = false ) {
|
||||
$dbr = $repo->getSlaveDB();
|
||||
$dbr = $repo->getReplicaDB();
|
||||
|
||||
$conds = [ 'oi_sha1' => $sha1 ];
|
||||
if ( $timestamp ) {
|
||||
|
|
@ -179,7 +179,7 @@ class OldLocalFile extends LocalFile {
|
|||
|
||||
$dbr = ( $flags & self::READ_LATEST )
|
||||
? $this->repo->getMasterDB()
|
||||
: $this->repo->getSlaveDB();
|
||||
: $this->repo->getReplicaDB();
|
||||
|
||||
$conds = [ 'oi_name' => $this->getName() ];
|
||||
if ( is_null( $this->requestedTime ) ) {
|
||||
|
|
@ -201,7 +201,7 @@ class OldLocalFile extends LocalFile {
|
|||
*/
|
||||
protected function loadExtraFromDB() {
|
||||
$this->extraDataLoaded = true;
|
||||
$dbr = $this->repo->getSlaveDB();
|
||||
$dbr = $this->repo->getReplicaDB();
|
||||
$conds = [ 'oi_name' => $this->getName() ];
|
||||
if ( is_null( $this->requestedTime ) ) {
|
||||
$conds['oi_archive_name'] = $this->archive_name;
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ class WikiFilePage extends WikiPage {
|
|||
|
||||
/** @var LocalRepo $repo */
|
||||
$repo = $file->getRepo();
|
||||
$dbr = $repo->getSlaveDB();
|
||||
$dbr = $repo->getReplicaDB();
|
||||
|
||||
$res = $dbr->select(
|
||||
[ 'page', 'categorylinks' ],
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ class UploadStash {
|
|||
. ' No user is logged in, files must belong to users' );
|
||||
}
|
||||
|
||||
$dbr = $this->repo->getSlaveDB();
|
||||
$dbr = $this->repo->getReplicaDB();
|
||||
$res = $dbr->select(
|
||||
'uploadstash',
|
||||
'us_key',
|
||||
|
|
@ -511,7 +511,7 @@ class UploadStash {
|
|||
// sometimes reading from the master is necessary, if there's replication lag.
|
||||
$dbr = $this->repo->getMasterDB();
|
||||
} else {
|
||||
$dbr = $this->repo->getSlaveDB();
|
||||
$dbr = $this->repo->getReplicaDB();
|
||||
}
|
||||
|
||||
$row = $dbr->selectRow(
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class UploadStashCleanup extends Maintenance {
|
|||
$repo = RepoGroup::singleton()->getLocalRepo();
|
||||
$tempRepo = $repo->getTempRepo();
|
||||
|
||||
$dbr = $repo->getSlaveDB();
|
||||
$dbr = $repo->getReplicaDB();
|
||||
|
||||
// how far back should this look for files to delete?
|
||||
$cutoff = time() - $wgUploadStashMaxAge;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class FindMissingFiles extends Maintenance {
|
|||
$lastName = $this->getOption( 'start', '' );
|
||||
|
||||
$repo = RepoGroup::singleton()->getLocalRepo();
|
||||
$dbr = $repo->getSlaveDB();
|
||||
$dbr = $repo->getReplicaDB();
|
||||
$be = $repo->getBackend();
|
||||
|
||||
$mtime1 = $dbr->timestampOrNull( $this->getOption( 'mtimeafter', null ) );
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class FindOrphanedFiles extends Maintenance {
|
|||
return;
|
||||
}
|
||||
|
||||
$dbr = $repo->getSlaveDB();
|
||||
$dbr = $repo->getReplicaDB();
|
||||
|
||||
$curNames = [];
|
||||
$oldNames = [];
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class PurgeChangedFiles extends Maintenance {
|
|||
}
|
||||
|
||||
protected function purgeFromArchiveTable( LocalRepo $repo, LocalFile $file ) {
|
||||
$dbr = $repo->getSlaveDB();
|
||||
$dbr = $repo->getReplicaDB();
|
||||
$res = $dbr->select(
|
||||
'filearchive',
|
||||
[ 'fa_archive_name' ],
|
||||
|
|
|
|||
Loading…
Reference in a new issue