From deaf6b0e5d4bd659f5f0ec112133f53eba84c03f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 6 Apr 2019 16:29:36 -0700 Subject: [PATCH] Change Database type hints to use IDatabase Change-Id: Ie1e86cd961a619335138402ba22fe2a73a3e62fd --- includes/Title.php | 2 +- includes/user/User.php | 2 +- tests/phpunit/MediaWikiTestCase.php | 7 ++++--- tests/phpunit/includes/db/LBFactoryTest.php | 3 +-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 3d54750cea..b05e1709e1 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2730,7 +2730,7 @@ class Title implements LinkTarget, IDBAccessObject { $id = $this->getArticleID(); if ( $id ) { $fname = __METHOD__; - $loadRestrictionsFromDb = function ( Database $dbr ) use ( $fname, $id ) { + $loadRestrictionsFromDb = function ( IDatabase $dbr ) use ( $fname, $id ) { return iterator_to_array( $dbr->select( 'page_restrictions', diff --git a/includes/user/User.php b/includes/user/User.php index 311cac225c..58ea17bf4c 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1675,7 +1675,7 @@ class User implements IDBAccessObject, UserIdentity { * @param array $conditions WHERE conditions for use with Database::update * @return array WHERE conditions for use with Database::update */ - protected function makeUpdateConditions( Database $db, array $conditions ) { + protected function makeUpdateConditions( IDatabase $db, array $conditions ) { if ( $this->mTouched ) { // CAS check: only update if the row wasn't changed sicne it was loaded. $conditions['user_touched'] = $db->timestamp( $this->mTouched ); diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 5119d737f2..8a38f42b41 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -401,7 +401,8 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { self::$useTemporaryTables = !$this->getCliArg( 'use-normal-tables' ); self::$reuseDB = $this->getCliArg( 'reuse-db' ); - $this->db = wfGetDB( DB_MASTER ); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); + $this->db = $lb->getConnection( DB_MASTER ); $this->checkDbIsSupported(); @@ -1457,12 +1458,12 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { * @note this method only works when first called. Subsequent calls have no effect, * even if using different parameters. * - * @param Database $db The database connection + * @param IMaintainableDatabase $db The database connection * @param string $prefix The prefix to use for the new table set (aka schema). * * @throws MWException If the database table prefix is already $prefix */ - public static function setupTestDB( Database $db, $prefix ) { + public static function setupTestDB( IMaintainableDatabase $db, $prefix ) { if ( self::$dbSetup ) { return; } diff --git a/tests/phpunit/includes/db/LBFactoryTest.php b/tests/phpunit/includes/db/LBFactoryTest.php index 02c25e7b0d..7d13ac6ea6 100644 --- a/tests/phpunit/includes/db/LBFactoryTest.php +++ b/tests/phpunit/includes/db/LBFactoryTest.php @@ -23,7 +23,6 @@ * @copyright © 2013 Wikimedia Foundation Inc. */ -use Wikimedia\Rdbms\Database; use Wikimedia\Rdbms\IDatabase; use Wikimedia\Rdbms\IMaintainableDatabase; use Wikimedia\Rdbms\LBFactory; @@ -730,7 +729,7 @@ class LBFactoryTest extends MediaWikiTestCase { $factory->destroy(); } - private function quoteTable( Database $db, $table ) { + private function quoteTable( IDatabase $db, $table ) { if ( $db->getType() === 'sqlite' ) { return $table; } else { -- 2.20.1