The old name is left as an alias.
Change-Id: I60ab2cd5ce05df4247d5e25b017d2debee56554e
* 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() {
/**
* @return IDatabase
*/
- function getSlaveDB() {
+ function getReplicaDB() {
return $this->getMasterDB();
}
/**
* @return IDatabase
*/
- function getSlaveDB() {
+ function getReplicaDB() {
return wfGetLB( $this->wiki )->getConnectionRef( DB_REPLICA, [], $this->wiki );
}
$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 );
}
};
- $dbr = $this->getSlaveDB();
+ $dbr = $this->getReplicaDB();
// Query image table
$imgNames = [];
* @return File[]
*/
function findBySha1( $hash ) {
- $dbr = $this->getSlaveDB();
+ $dbr = $this->getReplicaDB();
$res = $dbr->select(
'image',
LocalFile::selectFields(),
return []; // empty parameter
}
- $dbr = $this->getSlaveDB();
+ $dbr = $this->getReplicaDB();
$res = $dbr->select(
'image',
LocalFile::selectFields(),
$selectOptions = [ 'ORDER BY' => 'img_name', 'LIMIT' => intval( $limit ) ];
// Query database
- $dbr = $this->getSlaveDB();
+ $dbr = $this->getReplicaDB();
$res = $dbr->select(
'image',
LocalFile::selectFields(),
* 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
return false;
}
- $touched = $this->repo->getSlaveDB()->selectField(
+ $touched = $this->repo->getReplicaDB()->selectField(
'page',
'page_touched',
[
* @since 1.27
*/
public function getDescriptionShortUrl() {
- $dbr = $this->repo->getSlaveDB();
+ $dbr = $this->repo->getReplicaDB();
$pageId = $dbr->selectField(
'page',
'page_id',
* @return bool|LocalFile
*/
static function newFromKey( $sha1, $repo, $timestamp = false ) {
- $dbr = $repo->getSlaveDB();
+ $dbr = $repo->getReplicaDB();
$conds = [ 'img_sha1' => $sha1 ];
if ( $timestamp ) {
$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 );
$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 );
# 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 );
}
$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';
* @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 = [];
# 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',
'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;
}
* @return bool|OldLocalFile
*/
static function newFromKey( $sha1, $repo, $timestamp = false ) {
- $dbr = $repo->getSlaveDB();
+ $dbr = $repo->getReplicaDB();
$conds = [ 'oi_sha1' => $sha1 ];
if ( $timestamp ) {
$dbr = ( $flags & self::READ_LATEST )
? $this->repo->getMasterDB()
- : $this->repo->getSlaveDB();
+ : $this->repo->getReplicaDB();
$conds = [ 'oi_name' => $this->getName() ];
if ( is_null( $this->requestedTime ) ) {
*/
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;
/** @var LocalRepo $repo */
$repo = $file->getRepo();
- $dbr = $repo->getSlaveDB();
+ $dbr = $repo->getReplicaDB();
$res = $dbr->select(
[ 'page', 'categorylinks' ],
. ' No user is logged in, files must belong to users' );
}
- $dbr = $this->repo->getSlaveDB();
+ $dbr = $this->repo->getReplicaDB();
$res = $dbr->select(
'uploadstash',
'us_key',
// 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(
$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;
$lastName = $this->getOption( 'start', '' );
$repo = RepoGroup::singleton()->getLocalRepo();
- $dbr = $repo->getSlaveDB();
+ $dbr = $repo->getReplicaDB();
$be = $repo->getBackend();
$mtime1 = $dbr->timestampOrNull( $this->getOption( 'mtimeafter', null ) );
return;
}
- $dbr = $repo->getSlaveDB();
+ $dbr = $repo->getReplicaDB();
$curNames = [];
$oldNames = [];
}
protected function purgeFromArchiveTable( LocalRepo $repo, LocalFile $file ) {
- $dbr = $repo->getSlaveDB();
+ $dbr = $repo->getReplicaDB();
$res = $dbr->select(
'filearchive',
[ 'fa_archive_name' ],