From 8785e4a5b3733fdfeb865e13db458077f68dd88f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 4 Aug 2017 20:53:34 +0200 Subject: [PATCH] Replace remaining uses of deprecated DB_SLAVE with DB_REPLICA Change 950cf6016c10953213e5f985dfc18a32d8673197 took care of the most, but a few remain, either outside of includes/ and maintenance/ directories (which that change was limited to), or in code introduced afterwards. Change-Id: I9c363d0219ea7e71cde520faba39406949a36d27 --- docs/database.txt | 2 +- includes/specials/SpecialUncategorizedcategories.php | 2 +- languages/Language.php | 2 +- profileinfo.php | 2 +- tests/phpunit/MediaWikiTestCase.php | 2 +- tests/phpunit/includes/RevisionStorageTest.php | 6 +++--- .../includes/WatchedItemQueryServiceUnitTest.php | 2 +- tests/phpunit/includes/WatchedItemStoreUnitTest.php | 2 +- tests/phpunit/includes/db/LBFactoryTest.php | 8 ++++---- tests/phpunit/includes/page/WikiPageTest.php | 10 +++++----- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/database.txt b/docs/database.txt index 44ec764d95..dbc92044de 100644 --- a/docs/database.txt +++ b/docs/database.txt @@ -17,7 +17,7 @@ description of the tables and their contents, please see: 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 ) { ... diff --git a/includes/specials/SpecialUncategorizedcategories.php b/includes/specials/SpecialUncategorizedcategories.php index 77b6926457..5ff9e04ef7 100644 --- a/includes/specials/SpecialUncategorizedcategories.php +++ b/includes/specials/SpecialUncategorizedcategories.php @@ -68,7 +68,7 @@ class UncategorizedCategoriesPage extends UncategorizedPagesPage { } public function getQueryInfo() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $query = parent::getQueryInfo(); $exceptionList = $this->getExceptionList(); if ( $exceptionList ) { diff --git a/languages/Language.php b/languages/Language.php index 12f26c3b9f..941f4b8fdc 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -4537,7 +4537,7 @@ class Language { 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 ) { diff --git a/profileinfo.php b/profileinfo.php index 466f26aaec..83ae1935df 100644 --- a/profileinfo.php +++ b/profileinfo.php @@ -150,7 +150,7 @@ if ( !$wgEnableProfileInfo ) { exit( 1 ); } -$dbr = wfGetDB( DB_SLAVE ); +$dbr = wfGetDB( DB_REPLICA ); if ( !$dbr->tableExists( 'profiling' ) ) { echo '

No profiling table exists, so we can\'t show you anything.

' diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 215d292410..4afe710580 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1490,7 +1490,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { ' 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() ); diff --git a/tests/phpunit/includes/RevisionStorageTest.php b/tests/phpunit/includes/RevisionStorageTest.php index 642ada20f2..3ba82a6f59 100644 --- a/tests/phpunit/includes/RevisionStorageTest.php +++ b/tests/phpunit/includes/RevisionStorageTest.php @@ -145,7 +145,7 @@ class RevisionStorageTest extends MediaWikiTestCase { 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' ); @@ -163,7 +163,7 @@ class RevisionStorageTest extends MediaWikiTestCase { 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' ); @@ -187,7 +187,7 @@ class RevisionStorageTest extends MediaWikiTestCase { $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' ); diff --git a/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php b/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php index 6b436a8d6d..958d70acd2 100644 --- a/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php +++ b/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php @@ -58,7 +58,7 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { ->getMock(); $mock->expects( $this->any() ) ->method( 'getConnectionRef' ) - ->with( DB_SLAVE ) + ->with( DB_REPLICA ) ->will( $this->returnValue( $mockDb ) ); return $mock; } diff --git a/tests/phpunit/includes/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/WatchedItemStoreUnitTest.php index fa81eb1f23..6c1859921c 100644 --- a/tests/phpunit/includes/WatchedItemStoreUnitTest.php +++ b/tests/phpunit/includes/WatchedItemStoreUnitTest.php @@ -1466,7 +1466,7 @@ class WatchedItemStoreUnitTest extends MediaWikiTestCase { public function provideDbTypes() { return [ - [ false, DB_SLAVE ], + [ false, DB_REPLICA ], [ true, DB_MASTER ], ]; } diff --git a/tests/phpunit/includes/db/LBFactoryTest.php b/tests/phpunit/includes/db/LBFactoryTest.php index 049f81f383..1efeeebdaf 100644 --- a/tests/phpunit/includes/db/LBFactoryTest.php +++ b/tests/phpunit/includes/db/LBFactoryTest.php @@ -88,8 +88,8 @@ class LBFactoryTest extends MediaWikiTestCase { $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(); @@ -134,7 +134,7 @@ class LBFactoryTest extends MediaWikiTestCase { $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', @@ -175,7 +175,7 @@ class LBFactoryTest extends MediaWikiTestCase { $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(); diff --git a/tests/phpunit/includes/page/WikiPageTest.php b/tests/phpunit/includes/page/WikiPageTest.php index 3079d8f227..a9f74b6472 100644 --- a/tests/phpunit/includes/page/WikiPageTest.php +++ b/tests/phpunit/includes/page/WikiPageTest.php @@ -117,7 +117,7 @@ class WikiPageTest extends MediaWikiLangTestCase { $id = $page->getId(); # ------------------------ - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] ); $n = $res->numRows(); $res->free(); @@ -147,7 +147,7 @@ class WikiPageTest extends MediaWikiLangTestCase { $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(); @@ -195,7 +195,7 @@ class WikiPageTest extends MediaWikiLangTestCase { $jobs->execute(); # ------------------------ - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] ); $n = $res->numRows(); $res->free(); @@ -225,7 +225,7 @@ class WikiPageTest extends MediaWikiLangTestCase { $jobs->execute(); # ------------------------ - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] ); $n = $res->numRows(); $res->free(); @@ -827,7 +827,7 @@ more stuff # 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() ); -- 2.20.1