To make a read query, something like this usually suffices:
-$dbr = wfGetDB( DB_SLAVE );
+$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( /* ...see docs... */ );
foreach ( $res as $row ) {
...
}
public function getQueryInfo() {
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$query = parent::getQueryInfo();
$exceptionList = $this->getExceptionList();
if ( $exceptionList ) {
public function formatExpiry( $expiry, $format = true, $infinity = 'infinity' ) {
static $dbInfinity;
if ( $dbInfinity === null ) {
- $dbInfinity = wfGetDB( DB_SLAVE )->getInfinity();
+ $dbInfinity = wfGetDB( DB_REPLICA )->getInfinity();
}
if ( $expiry == '' || $expiry === 'infinity' || $expiry == $dbInfinity ) {
exit( 1 );
}
-$dbr = wfGetDB( DB_SLAVE );
+$dbr = wfGetDB( DB_REPLICA );
if ( !$dbr->tableExists( 'profiling' ) ) {
echo '<p>No <code>profiling</code> table exists, so we can\'t show you anything.</p>'
' method should return true. Use @group Database or $this->tablesUsed.' );
}
- $db = wfGetDB( DB_SLAVE );
+ $db = wfGetDB( DB_REPLICA );
$res = $db->select( $table, $fields, $condition, wfGetCaller(), [ 'ORDER BY' => $fields ] );
$this->assertNotEmpty( $res, "query failed: " . $db->lastError() );
public function testConstructFromRow() {
$orig = $this->makeRevision();
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'revision', '*', [ 'rev_id' => $orig->getId() ] );
$this->assertTrue( is_object( $res ), 'query failed' );
public function testNewFromRow() {
$orig = $this->makeRevision();
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'revision', '*', [ 'rev_id' => $orig->getId() ] );
$this->assertTrue( is_object( $res ), 'query failed' );
$orig = $page->getRevision();
$page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'archive', '*', [ 'ar_rev_id' => $orig->getId() ] );
$this->assertTrue( is_object( $res ), 'query failed' );
->getMock();
$mock->expects( $this->any() )
->method( 'getConnectionRef' )
- ->with( DB_SLAVE )
+ ->with( DB_REPLICA )
->will( $this->returnValue( $mockDb ) );
return $mock;
}
public function provideDbTypes() {
return [
- [ false, DB_SLAVE ],
+ [ false, DB_REPLICA ],
[ true, DB_MASTER ],
];
}
$dbw = $lb->getConnection( DB_MASTER );
$this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
- $dbr = $lb->getConnection( DB_SLAVE );
- $this->assertTrue( $dbr->getLBInfo( 'master' ), 'DB_SLAVE also gets the master' );
+ $dbr = $lb->getConnection( DB_REPLICA );
+ $this->assertTrue( $dbr->getLBInfo( 'master' ), 'DB_REPLICA also gets the master' );
$factory->shutdown();
$lb->closeAll();
$dbw->getLBInfo( 'clusterMasterHost' ),
'cluster master set' );
- $dbr = $lb->getConnection( DB_SLAVE );
+ $dbr = $lb->getConnection( DB_REPLICA );
$this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
$this->assertEquals(
( $wgDBserver != '' ) ? $wgDBserver : 'localhost',
$dbw = $lb->getConnection( DB_MASTER );
$this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
- $dbr = $lb->getConnection( DB_SLAVE );
+ $dbr = $lb->getConnection( DB_REPLICA );
$this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
$factory->shutdown();
$id = $page->getId();
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$this->assertTrue( $content->equals( $retrieved ), 'retrieved content doesn\'t equal original' );
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$jobs->execute();
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$jobs->execute();
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
# we are having issues with doRollback spuriously failing. Apparently
# the last revision somehow goes missing or not committed under some
# circumstances. So, make sure the last revision has the right user name.
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$this->assertEquals( 3, Revision::countByPageId( $dbr, $page->getId() ) );
$page = new WikiPage( $page->getTitle() );