DB_SLAVE -> DB_REPLICA

Change-Id: I371e092b3cd7f0af3770bf4e64b01a630e23ff92
This commit is contained in:
Max Semenik 2017-08-29 19:51:39 -07:00
parent 13b60c5e35
commit 0686f99653
12 changed files with 36 additions and 36 deletions

View file

@ -119,7 +119,7 @@ class AFComputedVariable {
return [];
}
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select(
'externallinks',
[ 'el_to' ],
@ -373,7 +373,7 @@ class AFComputedVariable {
case 'revision-text-by-timestamp':
$timestamp = $parameters['timestamp'];
$title = Title::makeTitle( $parameters['namespace'], $parameters['title'] );
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$rev = Revision::loadFromTimestamp( $dbr, $title, $timestamp );
$result = AbuseFilter::revisionToString( $rev );
break;
@ -403,7 +403,7 @@ class AFComputedVariable {
$cache->makeKey( 'last-10-authors', 'revision', $title->getLatestRevID() ),
$cache::TTL_MINUTE,
function ( $oldValue, &$ttl, array &$setOpts ) use ( $title ) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$setOpts += Database::getCacheSetOptions( $dbr );
// Get the last 100 edit authors with a trivial query (avoid T116557)
$revAuthors = $dbr->selectFieldValues(

View file

@ -287,10 +287,10 @@ class AbuseFilter {
if ( !$wgAbuseFilterCentralDB ) {
return false;
}
$dbr = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB );
$dbr = wfGetDB( DB_REPLICA, [], $wgAbuseFilterCentralDB );
$filter = $globalIndex;
} else {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
}
if ( $filter === 'new' ) {
return false;
@ -459,7 +459,7 @@ class AbuseFilter {
// Fetch from the database.
$filter_matched = [];
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select(
'abuse_filter',
'*',
@ -487,7 +487,7 @@ class AbuseFilter {
global $wgAbuseFilterCentralDB;
$fdb = wfGetLB( $wgAbuseFilterCentralDB )->getConnectionRef(
DB_SLAVE, [], $wgAbuseFilterCentralDB
DB_REPLICA, [], $wgAbuseFilterCentralDB
);
return iterator_to_array( $fdb->select(
@ -675,7 +675,7 @@ class AbuseFilter {
global $wgAbuseFilterCentralDB;
// Load local filter info
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
// Retrieve the consequences.
$consequences = [];
@ -684,7 +684,7 @@ class AbuseFilter {
}
if ( count( $globalFilters ) ) {
$fdb = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB );
$fdb = wfGetDB( DB_REPLICA, [], $wgAbuseFilterCentralDB );
$consequences = $consequences + self::loadConsequencesFromDB( $fdb, $globalFilters, 'global-' );
}
@ -981,7 +981,7 @@ class AbuseFilter {
$log_template = [
'afl_user' => $user->getId(),
'afl_user_text' => $user->getName(),
'afl_timestamp' => wfGetDB( DB_SLAVE )->timestamp( wfTimestampNow() ),
'afl_timestamp' => wfGetDB( DB_REPLICA )->timestamp( wfTimestampNow() ),
'afl_namespace' => $title->getNamespace(),
'afl_title' => $title->getDBkey(),
'afl_ip' => $wgRequest->getIP()
@ -1027,10 +1027,10 @@ class AbuseFilter {
$id = $globalIndex;
$lb = wfGetLB( $wgAbuseFilterCentralDB );
$dbr = $lb->getConnectionRef( DB_SLAVE, [], $wgAbuseFilterCentralDB );
$dbr = $lb->getConnectionRef( DB_REPLICA, [], $wgAbuseFilterCentralDB );
} else {
// Local wiki filter
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
}
$row = $dbr->selectRow( 'abuse_filter', '*', [ 'af_id' => $id ], __METHOD__ );
@ -1314,7 +1314,7 @@ class AbuseFilter {
$text_id = substr( $stored_dump, strlen( 'stored-text:' ) );
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$text_row = $dbr->selectRow(
'text',
@ -2418,7 +2418,7 @@ class AbuseFilter {
return $cache[$filterID];
}
$fdb = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB );
$fdb = wfGetDB( DB_REPLICA, [], $wgAbuseFilterCentralDB );
$cache[$filterID] = $fdb->selectField(
'abuse_filter',
@ -2518,7 +2518,7 @@ class AbuseFilter {
static $firstChanges = [];
if ( !isset( $firstChanges[$filterID] ) ) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'abuse_filter_history',
'afh_id',

View file

@ -514,7 +514,7 @@ class AbuseFilterHooks {
}
if ( $wgAbuseFilterCentralDB && !$wgAbuseFilterIsCentral ) {
$dbr = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB );
$dbr = wfGetDB( DB_REPLICA, [], $wgAbuseFilterCentralDB );
$where['af_global'] = 1;
$res = $dbr->select(
[ 'abuse_filter_action', 'abuse_filter' ],

View file

@ -128,7 +128,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
* @return int|null Id of the next change or null if there isn't one
*/
function getNextHistoryId( $historyId ) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'abuse_filter_history',
'afh_id',
@ -153,7 +153,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
return $cache[$spec];
}
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = null;
if ( is_numeric( $spec ) ) {
$row = $dbr->selectRow(

View file

@ -88,7 +88,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
$filter = $this->mFilter;
$history_id = $this->mHistoryID;
if ( $this->mHistoryID ) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'abuse_filter_history',
'afh_id',
@ -878,7 +878,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
$existingSelector->setAttribute( 'disabled', 'disabled' );
} else {
// Find other messages.
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select(
'page',
[ 'page_title' ],
@ -926,7 +926,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
// Load from master to avoid unintended reversions where there's replication lag.
$dbr = $this->getRequest()->wasPosted()
? wfGetDB( DB_MASTER )
: wfGetDB( DB_SLAVE );
: wfGetDB( DB_REPLICA );
// Load certain fields only. This prevents a condition seen on Wikimedia where
// a schema change adding a new field caused that extra field to be selected.
@ -1098,7 +1098,7 @@ class AbuseFilterViewEdit extends AbuseFilterView {
* Second element contains an array of abuse_filter_action rows.
*/
function loadHistoryItem( $id ) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
// Load the row.
$row = $dbr->selectRow( 'abuse_filter_history',

View file

@ -76,7 +76,7 @@ class AbuseFilterViewExamine extends AbuseFilterView {
function showExaminerForRC( $rcid ) {
// Get data
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow( 'recentchanges', '*', [ 'rc_id' => $rcid ], __METHOD__ );
$out = $this->getOutput();
if ( !$row ) {
@ -94,7 +94,7 @@ class AbuseFilterViewExamine extends AbuseFilterView {
function showExaminerForLogEntry( $logid ) {
// Get data
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow( 'abuse_filter_log', '*', [ 'afl_id' => $logid ], __METHOD__ );
$out = $this->getOutput();
@ -226,7 +226,7 @@ class AbuseFilterExaminePager extends ReverseChronologicalPager {
* @fixme this is similar to AbuseFilterViewTestBatch::doTest
*/
function getQueryInfo() {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$conds = [];
$conds['rc_user_text'] = $this->mPage->mSearchUser;

View file

@ -383,7 +383,7 @@ class GlobalAbuseFilterPager extends AbuseFilterPager {
function __construct( $page, $conds, $linkRenderer ) {
parent::__construct( $page, $conds, $linkRenderer );
global $wgAbuseFilterCentralDB;
$this->mDb = wfGetDB( DB_SLAVE, [], $wgAbuseFilterCentralDB );
$this->mDb = wfGetDB( DB_REPLICA, [], $wgAbuseFilterCentralDB );
}
function formatValue( $name, $value ) {

View file

@ -111,7 +111,7 @@ class AbuseFilterViewRevert extends AbuseFilterView {
$conds = [ 'afl_filter' => $filter ];
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
if ( $periodStart ) {
$conds[] = 'afl_timestamp>' . $dbr->addQuotes( $dbr->timestamp( $periodStart ) );

View file

@ -89,7 +89,7 @@ class AbuseFilterViewTestBatch extends AbuseFilterView {
$out->addWikiMsg( 'abusefilter-test-syntaxerr' );
return;
}
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$conds = [];
$conds['rc_user_text'] = $this->mTestUser;
@ -167,7 +167,7 @@ class AbuseFilterViewTestBatch extends AbuseFilterView {
&& count( $this->mParams ) > 1
&& is_numeric( $this->mParams[1] )
) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$this->mFilter = $dbr->selectField( 'abuse_filter',
'af_pattern',
[ 'af_id' => $this->mParams[1] ],

View file

@ -18,7 +18,7 @@ class ApiAbuseFilterCheckMatch extends ApiBase {
$vars->setVar( $name, $value );
}
} elseif ( $params['rcid'] ) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'recentchanges',
'*',
@ -32,7 +32,7 @@ class ApiAbuseFilterCheckMatch extends ApiBase {
$vars = AbuseFilter::getVarsFromRCRow( $row );
} elseif ( $params['logid'] ) {
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
'abuse_filter_log',
'*',

View file

@ -163,7 +163,7 @@ class SpecialAbuseLog extends SpecialPage {
return;
}
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
[ 'abuse_filter_log', 'abuse_filter' ],
@ -291,7 +291,7 @@ class SpecialAbuseLog extends SpecialPage {
if ( $this->mSearchEntries == '1' ) {
$conds['afl_deleted'] = 1;
} elseif ( $this->mSearchEntries == '2' ) {
$conds[] = self::getNotDeletedCond( wfGetDB( DB_SLAVE ) );
$conds[] = self::getNotDeletedCond( wfGetDB( DB_REPLICA ) );
}
}
@ -314,7 +314,7 @@ class SpecialAbuseLog extends SpecialPage {
function showDetails( $id ) {
$out = $this->getOutput();
$dbr = wfGetDB( DB_SLAVE );
$dbr = wfGetDB( DB_REPLICA );
$row = $dbr->selectRow(
[ 'abuse_filter_log', 'abuse_filter' ],

View file

@ -21,7 +21,7 @@ class AddMissingLoggingEntries extends Maintenance {
$afhRows = [];
// Find all entries in abuse_filter_history without logging entry of same timestamp
$afhResult = wfGetDB( DB_SLAVE, 'vslow' )->select(
$afhResult = wfGetDB( DB_REPLICA, 'vslow' )->select(
[ 'abuse_filter_history', 'logging' ],
[ 'afh_id', 'afh_filter', 'afh_timestamp', 'afh_user', 'afh_deleted', 'afh_user_text' ],
[ 'log_id IS NULL' ],
@ -46,7 +46,7 @@ class AddMissingLoggingEntries extends Maintenance {
$this->error( "Nothing to do.", 1 );
}
$logResult = wfGetDB( DB_SLAVE )->select(
$logResult = wfGetDB( DB_REPLICA )->select(
'logging',
[ 'log_params' ],
[ 'log_type' => 'abusefilter', 'log_params' => $logParams ],