jenkins-bot has submitted this change and it was merged. Change subject: Replace DatabaseBase:: with Database:: and update type hints ......................................................................
Replace DatabaseBase:: with Database:: and update type hints Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511 --- M includes/MergeHistory.php M includes/WatchedItemQueryService.php M includes/WatchedItemStore.php M includes/cache/LinkBatch.php M includes/changes/ChangesFeed.php M includes/changetags/ChangeTags.php M includes/dao/DBAccessBase.php M includes/db/DatabaseMssql.php M includes/filerepo/ForeignDBRepo.php M includes/filerepo/file/LocalFile.php M includes/installer/DatabaseUpdater.php M includes/installer/MssqlInstaller.php M includes/installer/MysqlInstaller.php M includes/installer/PostgresInstaller.php M includes/installer/SqliteInstaller.php M includes/libs/lockmanager/DBLockManager.php M includes/libs/rdbms/TransactionProfiler.php M includes/libs/rdbms/database/Database.php M includes/libs/rdbms/database/DatabaseSqlite.php M includes/libs/rdbms/database/IDatabase.php M includes/libs/rdbms/encasing/LikeMatch.php M includes/libs/rdbms/exception/DBQueryError.php M includes/libs/rdbms/loadbalancer/LoadBalancer.php M includes/objectcache/SqlBagOStuff.php M includes/page/WikiPage.php M includes/user/User.php M tests/parser/ParserTestRunner.php M tests/phpunit/MediaWikiTestCase.php M tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php M tests/phpunit/includes/db/DatabaseMysqlBaseTest.php M tests/phpunit/includes/db/DatabaseSQLTest.php M tests/phpunit/includes/db/DatabaseSqliteTest.php M tests/phpunit/includes/db/DatabaseTest.php M tests/phpunit/includes/db/DatabaseTestHelper.php M tests/phpunit/includes/db/LBFactoryTest.php M tests/phpunit/includes/installer/DatabaseUpdaterTest.php M tests/phpunit/includes/utils/BatchRowUpdateTest.php 37 files changed, 139 insertions(+), 141 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/MergeHistory.php b/includes/MergeHistory.php index dd1fd37..f797fe3 100644 --- a/includes/MergeHistory.php +++ b/includes/MergeHistory.php @@ -42,7 +42,7 @@ /** @var Title Page to which history will be merged */ protected $dest; - /** @var DatabaseBase Database that we are using */ + /** @var IDatabase Database that we are using */ protected $dbw; /** @var MWTimestamp Maximum timestamp that we can use (oldest timestamp of dest) */ diff --git a/includes/WatchedItemQueryService.php b/includes/WatchedItemQueryService.php index 4ac4dea..c040fb1 100644 --- a/includes/WatchedItemQueryService.php +++ b/includes/WatchedItemQueryService.php @@ -63,10 +63,10 @@ } /** - * @param DatabaseBase $connection + * @param Database $connection * @throws MWException */ - private function reuseConnection( DatabaseBase $connection ) { + private function reuseConnection( Database $connection ) { $this->loadBalancer->reuseConnection( $connection ); } @@ -337,7 +337,7 @@ } private function getWatchedItemsWithRCInfoQueryConds( - DatabaseBase $db, + Database $db, User $user, array $options ) { @@ -445,7 +445,7 @@ return $conds; } - private function getStartEndConds( DatabaseBase $db, array $options ) { + private function getStartEndConds( Database $db, array $options ) { if ( !isset( $options['start'] ) && ! isset( $options['end'] ) ) { return []; } @@ -464,7 +464,7 @@ return $conds; } - private function getUserRelatedConds( DatabaseBase $db, User $user, array $options ) { + private function getUserRelatedConds( Database $db, User $user, array $options ) { if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) { return []; } @@ -491,7 +491,7 @@ return $conds; } - private function getExtraDeletedPageLogEntryRelatedCond( DatabaseBase $db, User $user ) { + private function getExtraDeletedPageLogEntryRelatedCond( Database $db, User $user ) { // LogPage::DELETED_ACTION hides the affected page, too. So hide those // entirely from the watchlist, or someone could guess the title. $bitmask = 0; @@ -509,7 +509,7 @@ return ''; } - private function getStartFromConds( DatabaseBase $db, array $options ) { + private function getStartFromConds( Database $db, array $options ) { $op = $options['dir'] === self::DIR_OLDER ? '<' : '>'; list( $rcTimestamp, $rcId ) = $options['startFrom']; $rcTimestamp = $db->addQuotes( $db->timestamp( $rcTimestamp ) ); @@ -529,7 +529,7 @@ ); } - private function getWatchedItemsForUserQueryConds( DatabaseBase $db, User $user, array $options ) { + private function getWatchedItemsForUserQueryConds( Database $db, User $user, array $options ) { $conds = [ 'wl_user' => $user->getId() ]; if ( $options['namespaceIds'] ) { $conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] ); @@ -563,12 +563,12 @@ * Creates a query condition part for getting only items before or after the given link target * (while ordering using $sort mode) * - * @param DatabaseBase $db + * @param Database $db * @param LinkTarget $target * @param string $op comparison operator to use in the conditions * @return string */ - private function getFromUntilTargetConds( DatabaseBase $db, LinkTarget $target, $op ) { + private function getFromUntilTargetConds( Database $db, LinkTarget $target, $op ) { return $db->makeList( [ "wl_namespace $op " . $target->getNamespace(), diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index 9a74401..478cc5f 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -200,7 +200,7 @@ } /** - * @param DatabaseBase $connection + * @param Database $connection * * @throws MWException */ diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php index 8a4d061..d773fff 100644 --- a/includes/cache/LinkBatch.php +++ b/includes/cache/LinkBatch.php @@ -236,7 +236,7 @@ * Construct a WHERE clause which will match all the given titles. * * @param string $prefix The appropriate table's field name prefix ('page', 'pl', etc) - * @param IDatabase $db DatabaseBase object to use + * @param IDatabase $db DB object to use * @return string|bool String with SQL where clause fragment, or false if no items. */ public function constructSet( $prefix, $db ) { diff --git a/includes/changes/ChangesFeed.php b/includes/changes/ChangesFeed.php index ca6ba48..15a00c7 100644 --- a/includes/changes/ChangesFeed.php +++ b/includes/changes/ChangesFeed.php @@ -164,7 +164,7 @@ /** * Generate the feed items given a row from the database, printing the feed. - * @param object $rows DatabaseBase resource with recentchanges rows + * @param object $rows IDatabase resource with recentchanges rows * @param ChannelFeed $feed */ public static function generateFeed( $rows, &$feed ) { @@ -178,7 +178,7 @@ /** * Generate the feed items given a row from the database. - * @param object $rows DatabaseBase resource with recentchanges rows + * @param object $rows IDatabase resource with recentchanges rows * @return array */ public static function buildItems( $rows ) { diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 6455a3a..955e972 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -608,10 +608,10 @@ * Handles selecting tags, and filtering. * Needs $tables to be set up properly, so we can figure out which join conditions to use. * - * @param string|array $tables Table names, see DatabaseBase::select - * @param string|array $fields Fields used in query, see DatabaseBase::select - * @param string|array $conds Conditions used in query, see DatabaseBase::select - * @param array $join_conds Join conditions, see DatabaseBase::select + * @param string|array $tables Table names, see Database::select + * @param string|array $fields Fields used in query, see Database::select + * @param string|array $conds Conditions used in query, see Database::select + * @param array $join_conds Join conditions, see Database::select * @param array $options Options, see Database::select * @param bool|string $filter_tag Tag to select on * diff --git a/includes/dao/DBAccessBase.php b/includes/dao/DBAccessBase.php index 01814c1..ed617fe 100644 --- a/includes/dao/DBAccessBase.php +++ b/includes/dao/DBAccessBase.php @@ -68,9 +68,9 @@ * * @since 1.21 * - * @param DatabaseBase $db The database connection to release. + * @param Database $db The database connection to release. */ - protected function releaseConnection( DatabaseBase $db ) { + protected function releaseConnection( Database $db ) { if ( $this->wiki !== false ) { $loadBalancer = $this->getLoadBalancer(); $loadBalancer->reuseConnection( $db ); diff --git a/includes/db/DatabaseMssql.php b/includes/db/DatabaseMssql.php index eb061d8..45ea54c 100644 --- a/includes/db/DatabaseMssql.php +++ b/includes/db/DatabaseMssql.php @@ -737,15 +737,15 @@ * UPDATE wrapper. Takes a condition array and a SET array. * * @param string $table Name of the table to UPDATE. This will be passed through - * DatabaseBase::tableName(). + * Database::tableName(). * * @param array $values An array of values to SET. For each array element, * the key gives the field name, and the value gives the data * to set that field to. The data will be quoted by - * DatabaseBase::addQuotes(). + * Database::addQuotes(). * * @param array $conds An array of conditions (WHERE). See - * DatabaseBase::select() for the details of the format of + * Database::select() for the details of the format of * condition arrays. Use '*' to update all rows. * * @param string $fname The function name of the caller (from __METHOD__), @@ -786,7 +786,7 @@ * @param int $mode Constant * - LIST_COMMA: comma separated, no field names * - LIST_AND: ANDed WHERE clause (without the WHERE). See - * the documentation for $conds in DatabaseBase::select(). + * the documentation for $conds in Database::select(). * - LIST_OR: ORed WHERE clause (without the WHERE) * - LIST_SET: comma separated with field names, like a SET clause * - LIST_NAMES: comma separated field names diff --git a/includes/filerepo/ForeignDBRepo.php b/includes/filerepo/ForeignDBRepo.php index 001800f..be046bd 100644 --- a/includes/filerepo/ForeignDBRepo.php +++ b/includes/filerepo/ForeignDBRepo.php @@ -106,7 +106,7 @@ ]; return function ( $index ) use ( $type, $params ) { - return DatabaseBase::factory( $type, $params ); + return Database::factory( $type, $params ); }; } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 60cfdac..7ffb147 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -2852,7 +2852,7 @@ protected $archive; - /** @var DatabaseBase */ + /** @var IDatabase */ protected $db; /** diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 2425005..fbdc934 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -101,11 +101,11 @@ /** * Constructor * - * @param DatabaseBase $db To perform updates on + * @param Database $db To perform updates on * @param bool $shared Whether to perform updates on shared tables * @param Maintenance $maintenance Maintenance object which created us */ - protected function __construct( DatabaseBase &$db, $shared, Maintenance $maintenance = null ) { + protected function __construct( Database &$db, $shared, Maintenance $maintenance = null ) { $this->db = $db; $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files $this->shared = $shared; diff --git a/includes/installer/MssqlInstaller.php b/includes/installer/MssqlInstaller.php index 62cd883..739be82 100644 --- a/includes/installer/MssqlInstaller.php +++ b/includes/installer/MssqlInstaller.php @@ -212,7 +212,7 @@ } try { - $db = DatabaseBase::factory( 'mssql', [ + $db = Database::factory( 'mssql', [ 'host' => $this->getVar( 'wgDBserver' ), 'user' => $user, 'password' => $password, @@ -261,7 +261,7 @@ if ( !$status->isOK() ) { return false; } - /** @var $conn DatabaseBase */ + /** @var $conn Database */ $conn = $status->value; // We need the server-level ALTER ANY LOGIN permission to create new accounts @@ -457,7 +457,7 @@ } try { - DatabaseBase::factory( 'mssql', [ + Database::factory( 'mssql', [ 'host' => $this->getVar( 'wgDBserver' ), 'user' => $user, 'password' => $password, @@ -491,7 +491,7 @@ if ( !$status->isOK() ) { return $status; } - /** @var DatabaseBase $conn */ + /** @var Database $conn */ $conn = $status->value; $dbName = $this->getVar( 'wgDBname' ); $schemaName = $this->getVar( 'wgDBmwschema' ); diff --git a/includes/installer/MysqlInstaller.php b/includes/installer/MysqlInstaller.php index 1bd3f51..812742c 100644 --- a/includes/installer/MysqlInstaller.php +++ b/includes/installer/MysqlInstaller.php @@ -143,7 +143,7 @@ public function openConnection() { $status = Status::newGood(); try { - $db = DatabaseBase::factory( 'mysql', [ + $db = Database::factory( 'mysql', [ 'host' => $this->getVar( 'wgDBserver' ), 'user' => $this->getVar( '_InstallUser' ), 'password' => $this->getVar( '_InstallPassword' ), @@ -261,7 +261,7 @@ if ( !$status->isOK() ) { return false; } - /** @var $conn DatabaseBase */ + /** @var $conn Database */ $conn = $status->value; // Get current account name @@ -427,7 +427,7 @@ if ( !$create ) { // Test the web account try { - DatabaseBase::factory( 'mysql', [ + Database::factory( 'mysql', [ 'host' => $this->getVar( 'wgDBserver' ), 'user' => $this->getVar( 'wgDBuser' ), 'password' => $this->getVar( 'wgDBpassword' ), @@ -471,7 +471,7 @@ if ( !$status->isOK() ) { return $status; } - /** @var DatabaseBase $conn */ + /** @var Database $conn */ $conn = $status->value; $dbName = $this->getVar( 'wgDBname' ); if ( !$conn->selectDB( $dbName ) ) { @@ -509,7 +509,7 @@ if ( $this->getVar( '_CreateDBAccount' ) ) { // Before we blindly try to create a user that already has access, try { // first attempt to connect to the database - DatabaseBase::factory( 'mysql', [ + Database::factory( 'mysql', [ 'host' => $server, 'user' => $dbUser, 'password' => $password, diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 0728415..7a2794d 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -154,7 +154,7 @@ protected function openConnectionWithParams( $user, $password, $dbName, $schema ) { $status = Status::newGood(); try { - $db = DatabaseBase::factory( 'postgres', [ + $db = Database::factory( 'postgres', [ 'host' => $this->getVar( 'wgDBserver' ), 'user' => $user, 'password' => $password, @@ -264,7 +264,7 @@ 'password' => $password, 'dbname' => $db ]; - $conn = DatabaseBase::factory( 'postgres', $p ); + $conn = Database::factory( 'postgres', $p ); } catch ( DBConnectionError $error ) { $conn = false; $status->fatal( 'config-pg-test-error', $db, @@ -413,7 +413,7 @@ /** * Recursive helper for canCreateObjectsForWebUser(). - * @param DatabaseBase $conn + * @param Database $conn * @param int $targetMember Role ID of the member to look for * @param int $group Role ID of the group to look for * @param int $maxDepth Maximum recursive search depth diff --git a/includes/installer/SqliteInstaller.php b/includes/installer/SqliteInstaller.php index 0adeddf..c5c4a7c 100644 --- a/includes/installer/SqliteInstaller.php +++ b/includes/installer/SqliteInstaller.php @@ -184,7 +184,7 @@ $dbName = $this->getVar( 'wgDBname' ); try { # @todo FIXME: Need more sensible constructor parameters, e.g. single associative array - $db = DatabaseBase::factory( 'sqlite', [ 'dbname' => $dbName, 'dbDirectory' => $dir ] ); + $db = Database::factory( 'sqlite', [ 'dbname' => $dbName, 'dbDirectory' => $dir ] ); $status->value = $db; } catch ( DBConnectionError $e ) { $status->fatal( 'config-sqlite-connection-error', $e->getMessage() ); @@ -239,7 +239,7 @@ # Create the global cache DB try { - $conn = DatabaseBase::factory( 'sqlite', [ 'dbname' => 'wikicache', 'dbDirectory' => $dir ] ); + $conn = Database::factory( 'sqlite', [ 'dbname' => 'wikicache', 'dbDirectory' => $dir ] ); # @todo: don't duplicate objectcache definition, though it's very simple $sql = <<<EOT diff --git a/includes/libs/lockmanager/DBLockManager.php b/includes/libs/lockmanager/DBLockManager.php index b058146..64a2916 100644 --- a/includes/libs/lockmanager/DBLockManager.php +++ b/includes/libs/lockmanager/DBLockManager.php @@ -148,7 +148,7 @@ } elseif ( is_array( $this->dbServers[$lockDb] ) ) { // Parameters to construct a new database connection $config = $this->dbServers[$lockDb]; - $db = DatabaseBase::factory( $config['type'], $config ); + $db = Database::factory( $config['type'], $config ); } else { throw new UnexpectedValueException( "No server called '$lockDb'." ); } diff --git a/includes/libs/rdbms/TransactionProfiler.php b/includes/libs/rdbms/TransactionProfiler.php index 5c9976d..4d2b28f 100644 --- a/includes/libs/rdbms/TransactionProfiler.php +++ b/includes/libs/rdbms/TransactionProfiler.php @@ -29,7 +29,7 @@ /** * Helper class that detects high-contention DB queries via profiling calls * - * This class is meant to work with a DatabaseBase object, which manages queries + * This class is meant to work with an IDatabase object, which manages queries * * @since 1.24 */ diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index 897e55f..2b058e9 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -128,7 +128,7 @@ * Either a short hexidecimal string if a transaction is active or "" * * @var string - * @see DatabaseBase::mTrxLevel + * @see Database::mTrxLevel */ protected $mTrxShortId = ''; /** @@ -137,7 +137,7 @@ * point (possibly more up-to-date since the first SELECT defines the snapshot). * * @var float|null - * @see DatabaseBase::mTrxLevel + * @see Database::mTrxLevel */ private $mTrxTimestamp = null; /** @var float Lag estimate at the time of BEGIN */ @@ -147,21 +147,21 @@ * Used to provide additional context for error reporting. * * @var string - * @see DatabaseBase::mTrxLevel + * @see Database::mTrxLevel */ private $mTrxFname = null; /** * Record if possible write queries were done in the last transaction started * * @var bool - * @see DatabaseBase::mTrxLevel + * @see Database::mTrxLevel */ private $mTrxDoneWrites = false; /** * Record if the current transaction was started implicitly due to DBO_TRX being set. * * @var bool - * @see DatabaseBase::mTrxLevel + * @see Database::mTrxLevel */ private $mTrxAutomatic = false; /** @@ -171,7 +171,7 @@ */ private $mTrxAtomicLevels = []; /** - * Record if the current transaction was started implicitly by DatabaseBase::startAtomic + * Record if the current transaction was started implicitly by Database::startAtomic * * @var bool */ @@ -1101,7 +1101,7 @@ * @param array $options Associative array of options to be turned into * an SQL query, valid keys are listed in the function. * @return array - * @see DatabaseBase::select() + * @see Database::select() */ protected function makeSelectOptions( $options ) { $preLimitTail = $postLimitTail = ''; @@ -1189,7 +1189,7 @@ * * @param array $options Associative array of options * @return string - * @see DatabaseBase::select() + * @see Database::select() * @since 1.21 */ protected function makeGroupByWithHaving( $options ) { @@ -1215,7 +1215,7 @@ * * @param array $options Associative array of options * @return string - * @see DatabaseBase::select() + * @see Database::select() * @since 1.21 */ protected function makeOrderBy( $options ) { @@ -1420,7 +1420,7 @@ } /** - * Helper for DatabaseBase::insert(). + * Helper for Database::insert(). * * @param array $options * @return string @@ -1482,7 +1482,7 @@ } /** - * Make UPDATE options array for DatabaseBase::makeUpdateOptions + * Make UPDATE options array for Database::makeUpdateOptions * * @param array $options * @return array @@ -1502,9 +1502,9 @@ } /** - * Make UPDATE options for the DatabaseBase::update function + * Make UPDATE options for the Database::update function * - * @param array $options The options passed to DatabaseBase::update + * @param array $options The options passed to Database::update * @return string */ protected function makeUpdateOptions( $options ) { @@ -2701,7 +2701,7 @@ /** * Issues the BEGIN command to the database server. * - * @see DatabaseBase::begin() + * @see Database::begin() * @param string $fname */ protected function doBegin( $fname ) { @@ -2760,7 +2760,7 @@ /** * Issues the COMMIT command to the database server. * - * @see DatabaseBase::commit() + * @see Database::commit() * @param string $fname */ protected function doCommit( $fname ) { @@ -2807,7 +2807,7 @@ /** * Issues the ROLLBACK command to the database server. * - * @see DatabaseBase::rollback() + * @see Database::rollback() * @param string $fname */ protected function doRollback( $fname ) { @@ -2884,7 +2884,7 @@ * necessary. Boolean values are passed through as is, to indicate success * of write queries or failure. * - * Once upon a time, DatabaseBase::query() returned a bare MySQL result + * Once upon a time, Database::query() returned a bare MySQL result * resource, and it was necessary to call this function to convert it to * a wrapper. Nowadays, raw database objects are never exposed to external * callers, so this is unnecessary in external code. diff --git a/includes/libs/rdbms/database/DatabaseSqlite.php b/includes/libs/rdbms/database/DatabaseSqlite.php index c33d3b3..156e525 100644 --- a/includes/libs/rdbms/database/DatabaseSqlite.php +++ b/includes/libs/rdbms/database/DatabaseSqlite.php @@ -117,7 +117,7 @@ $p['schema'] = false; $p['tablePrefix'] = ''; - return DatabaseBase::factory( 'sqlite', $p ); + return Database::factory( 'sqlite', $p ); } /** diff --git a/includes/libs/rdbms/database/IDatabase.php b/includes/libs/rdbms/database/IDatabase.php index 0396ec8..c32a7ff 100644 --- a/includes/libs/rdbms/database/IDatabase.php +++ b/includes/libs/rdbms/database/IDatabase.php @@ -613,7 +613,7 @@ * for use in field names (e.g. a.user_name). * * All of the table names given here are automatically run through - * DatabaseBase::tableName(), which causes the table prefix (if any) to be + * Database::tableName(), which causes the table prefix (if any) to be * added, and various other table name mappings to be performed. * * Do not use untrusted user input as a table name. Alias names should @@ -895,7 +895,7 @@ * IDatabase::affectedRows(). * * @param string $table Table name. This will be passed through - * DatabaseBase::tableName(). + * Database::tableName(). * @param array $a Array of rows to insert * @param string $fname Calling function name (use __METHOD__) for logs/profiling * @param array $options Array of options @@ -908,7 +908,7 @@ * UPDATE wrapper. Takes a condition array and a SET array. * * @param string $table Name of the table to UPDATE. This will be passed through - * DatabaseBase::tableName(). + * Database::tableName(). * @param array $values An array of values to SET. For each array element, * the key gives the field name, and the value gives the data to set * that field to. The data will be quoted by IDatabase::addQuotes(). @@ -1149,7 +1149,7 @@ * * @since 1.22 * - * @param string $table Table name. This will be passed through DatabaseBase::tableName(). + * @param string $table Table name. This will be passed through Database::tableName(). * @param array $rows A single row or list of rows to insert * @param array $uniqueIndexes List of single field names or field name tuples * @param array $set An array of values to SET. For each array element, the @@ -1463,8 +1463,8 @@ * * This can be an alternative to explicit startAtomic()/endAtomic() calls. * - * @see DatabaseBase::startAtomic - * @see DatabaseBase::endAtomic + * @see Database::startAtomic + * @see Database::endAtomic * * @param string $fname Caller name (usually __METHOD__) * @param callable $callback Callback that issues DB updates diff --git a/includes/libs/rdbms/encasing/LikeMatch.php b/includes/libs/rdbms/encasing/LikeMatch.php index 5dee884..b0b3c87 100644 --- a/includes/libs/rdbms/encasing/LikeMatch.php +++ b/includes/libs/rdbms/encasing/LikeMatch.php @@ -1,8 +1,8 @@ <?php /** - * Used by DatabaseBase::buildLike() to represent characters that have special + * Used by Database::buildLike() to represent characters that have special * meaning in SQL LIKE clauses and thus need no escaping. Don't instantiate it - * manually, use DatabaseBase::anyChar() and anyString() instead. + * manually, use Database::anyChar() and anyString() instead. */ class LikeMatch { /** @var string */ diff --git a/includes/libs/rdbms/exception/DBQueryError.php b/includes/libs/rdbms/exception/DBQueryError.php index ac9217d..002d253 100644 --- a/includes/libs/rdbms/exception/DBQueryError.php +++ b/includes/libs/rdbms/exception/DBQueryError.php @@ -40,7 +40,7 @@ * @param string $fname */ function __construct( IDatabase $db, $error, $errno, $sql, $fname ) { - if ( $db instanceof DatabaseBase && $db->wasConnectionError( $errno ) ) { + if ( $db instanceof Database && $db->wasConnectionError( $errno ) ) { $message = "A connection error occured. \n" . "Query: $sql\n" . "Function: $fname\n" . diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 36e4c6c6..a60e741 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1024,7 +1024,7 @@ } public function finalizeMasterChanges() { - $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) { + $this->forEachOpenMasterConnection( function ( Database $conn ) { // Any error should cause all DB transactions to be rolled back together $conn->setTrxEndCallbackSuppression( false ); $conn->runOnTransactionPreCommitCallbacks(); @@ -1077,7 +1077,7 @@ $failures = []; $this->forEachOpenMasterConnection( - function ( DatabaseBase $conn ) use ( $fname, &$failures ) { + function ( Database $conn ) use ( $fname, &$failures ) { $conn->setTrxEndCallbackSuppression( true ); try { $conn->flushSnapshot( $fname ); @@ -1131,7 +1131,7 @@ public function runMasterPostTrxCallbacks( $type ) { $e = null; // first exception - $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) use ( $type, &$e ) { + $this->forEachOpenMasterConnection( function ( Database $conn ) use ( $type, &$e ) { $conn->setTrxEndCallbackSuppression( false ); if ( $conn->writesOrCallbacksPending() ) { // This happens if onTransactionIdle() callbacks leave callbacks on *another* DB @@ -1178,7 +1178,7 @@ } public function suppressTransactionEndCallbacks() { - $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) { + $this->forEachOpenMasterConnection( function ( Database $conn ) { $conn->setTrxEndCallbackSuppression( true ); } ); } diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index d06213f..47dae78 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -182,7 +182,7 @@ $this->logger->debug( __CLASS__ . ": connecting to $host" ); // Use a blank trx profiler to ignore expections as this is a cache $info['trxProfiler'] = new TransactionProfiler(); - $db = DatabaseBase::factory( $type, $info ); + $db = Database::factory( $type, $info ); $db->clearFlag( DBO_TRX ); } else { $index = $this->replicaOnly ? DB_REPLICA : DB_MASTER; diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 50c5030..41e9e4f 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -3502,7 +3502,7 @@ $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'categorylinks', [ 'cl_to AS page_title, ' . NS_CATEGORY . ' AS page_namespace' ], - // Have to do that since DatabaseBase::fieldNamesWithAlias treats numeric indexes + // Have to do that since Database::fieldNamesWithAlias treats numeric indexes // as not being aliases, and NS_CATEGORY is numeric [ 'cl_from' => $id ], __METHOD__ ); diff --git a/includes/user/User.php b/includes/user/User.php index 0d06c7b..6083db9 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -1434,11 +1434,11 @@ * protected against race conditions using a compare-and-set (CAS) mechanism * based on comparing $this->mTouched with the user_touched field. * - * @param DatabaseBase $db - * @param array $conditions WHERE conditions for use with DatabaseBase::update - * @return array WHERE conditions for use with DatabaseBase::update + * @param Database $db + * @param array $conditions WHERE conditions for use with Database::update + * @return array WHERE conditions for use with Database::update */ - protected function makeUpdateConditions( DatabaseBase $db, array $conditions ) { + protected function makeUpdateConditions( Database $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/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index d2968a1..369cd0e 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -49,7 +49,7 @@ /** * Our connection to the database - * @var DatabaseBase + * @var Database */ private $db; diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index c952229..45a7ce5 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -42,7 +42,7 @@ /** * Primary database * - * @var DatabaseBase + * @var Database * @since 1.18 */ protected $db; @@ -1070,11 +1070,11 @@ * Clones all tables in the given database (whatever database that connection has * open), to versions with the test prefix. * - * @param DatabaseBase $db Database to use + * @param Database $db Database to use * @param string $prefix Prefix to use for test tables * @return bool True if tables were cloned, false if only the prefix was changed */ - protected static function setupDatabaseWithTestPrefix( DatabaseBase $db, $prefix ) { + protected static function setupDatabaseWithTestPrefix( Database $db, $prefix ) { $tablesCloned = self::listTables( $db ); $dbClone = new CloneDatabase( $db, $tablesCloned, $prefix ); $dbClone->useTemporaryTables( self::$useTemporaryTables ); @@ -1123,12 +1123,12 @@ * @note this method only works when first called. Subsequent calls have no effect, * even if using different parameters. * - * @param DatabaseBase $db The database connection + * @param Database $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( DatabaseBase $db, $prefix ) { + public static function setupTestDB( Database $db, $prefix ) { if ( self::$dbSetup ) { return; } @@ -1139,7 +1139,7 @@ } // TODO: the below should be re-written as soon as LBFactory, LoadBalancer, - // and DatabaseBase no longer use global state. + // and Database no longer use global state. self::$dbSetup = true; @@ -1178,7 +1178,7 @@ * Gets master database connections for all of the ExternalStoreDB * stores configured in $wgDefaultExternalStore. * - * @return DatabaseBase[] Array of DatabaseBase master connections + * @return Database[] Array of Database master connections */ protected static function getExternalStoreDatabaseConnections() { @@ -1192,7 +1192,7 @@ if ( strpos( $url, 'DB://' ) === 0 ) { list( $proto, $cluster ) = explode( '://', $url, 2 ); // Avoid getMaster() because setupDatabaseWithTestPrefix() - // requires DatabaseBase instead of plain DBConnRef/IDatabase + // requires Database instead of plain DBConnRef/IDatabase $lb = $externalStoreDB->getLoadBalancer( $cluster ); $dbw = $lb->getConnection( DB_MASTER ); $dbws[] = $dbw; @@ -1226,7 +1226,7 @@ /** * Empty all tables so they can be repopulated for tests * - * @param DatabaseBase $db|null Database to reset + * @param Database $db|null Database to reset * @param array $tablesUsed Tables to reset */ private function resetDB( $db, $tablesUsed ) { @@ -1309,11 +1309,11 @@ /** * @since 1.18 * - * @param DatabaseBase $db + * @param Database $db * * @return array */ - public static function listTables( DatabaseBase $db ) { + public static function listTables( Database $db ) { $prefix = $db->tablePrefix(); $tables = $db->listTables( $prefix, __METHOD__ ); diff --git a/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php b/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php index 1d232fe..93e0b57 100644 --- a/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php +++ b/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php @@ -6,10 +6,10 @@ class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase { /** - * @return PHPUnit_Framework_MockObject_MockObject|DatabaseBase + * @return PHPUnit_Framework_MockObject_MockObject|Database */ private function getMockDb() { - $mock = $this->getMockBuilder( DatabaseBase::class ) + $mock = $this->getMockBuilder( Database::class ) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php index c014e84..dbb126f 100644 --- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php +++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php @@ -29,7 +29,7 @@ * Fake class around abstract class so we can call concrete methods. */ class FakeDatabaseMysqlBase extends DatabaseMysqlBase { - // From DatabaseBase + // From Database function __construct() { $this->profiler = new ProfilerStub( [] ); $this->trxProfiler = new TransactionProfiler(); @@ -89,7 +89,6 @@ } - // From interface DatabaseType function insertId() { } diff --git a/tests/phpunit/includes/db/DatabaseSQLTest.php b/tests/phpunit/includes/db/DatabaseSQLTest.php index 68bc964..656e661 100644 --- a/tests/phpunit/includes/db/DatabaseSQLTest.php +++ b/tests/phpunit/includes/db/DatabaseSQLTest.php @@ -26,7 +26,7 @@ /** * @dataProvider provideSelect - * @covers DatabaseBase::select + * @covers Database::select */ public function testSelect( $sql, $sqlText ) { $this->database->select( @@ -132,7 +132,7 @@ /** * @dataProvider provideUpdate - * @covers DatabaseBase::update + * @covers Database::update */ public function testUpdate( $sql, $sqlText ) { $this->database->update( @@ -184,7 +184,7 @@ /** * @dataProvider provideDelete - * @covers DatabaseBase::delete + * @covers Database::delete */ public function testDelete( $sql, $sqlText ) { $this->database->delete( @@ -217,7 +217,7 @@ /** * @dataProvider provideUpsert - * @covers DatabaseBase::upsert + * @covers Database::upsert */ public function testUpsert( $sql, $sqlText ) { $this->database->upsert( @@ -253,7 +253,7 @@ /** * @dataProvider provideDeleteJoin - * @covers DatabaseBase::deleteJoin + * @covers Database::deleteJoin */ public function testDeleteJoin( $sql, $sqlText ) { $this->database->deleteJoin( @@ -300,7 +300,7 @@ /** * @dataProvider provideInsert - * @covers DatabaseBase::insert + * @covers Database::insert */ public function testInsert( $sql, $sqlText ) { $this->database->insert( @@ -353,7 +353,7 @@ /** * @dataProvider provideInsertSelect - * @covers DatabaseBase::insertSelect + * @covers Database::insertSelect */ public function testInsertSelect( $sql, $sqlTextNative, $sqlSelect, $sqlInsert ) { $this->database->insertSelect( @@ -440,7 +440,7 @@ /** * @dataProvider provideReplace - * @covers DatabaseBase::replace + * @covers Database::replace */ public function testReplace( $sql, $sqlText ) { $this->database->replace( @@ -555,7 +555,7 @@ /** * @dataProvider provideNativeReplace - * @covers DatabaseBase::nativeReplace + * @covers Database::nativeReplace */ public function testNativeReplace( $sql, $sqlText ) { $this->database->nativeReplace( @@ -582,7 +582,7 @@ /** * @dataProvider provideConditional - * @covers DatabaseBase::conditional + * @covers Database::conditional */ public function testConditional( $sql, $sqlText ) { $this->assertEquals( trim( $this->database->conditional( @@ -623,7 +623,7 @@ /** * @dataProvider provideBuildConcat - * @covers DatabaseBase::buildConcat + * @covers Database::buildConcat */ public function testBuildConcat( $stringList, $sqlText ) { $this->assertEquals( trim( $this->database->buildConcat( @@ -646,7 +646,7 @@ /** * @dataProvider provideBuildLike - * @covers DatabaseBase::buildLike + * @covers Database::buildLike */ public function testBuildLike( $array, $sqlText ) { $this->assertEquals( trim( $this->database->buildLike( @@ -677,7 +677,7 @@ /** * @dataProvider provideUnionQueries - * @covers DatabaseBase::unionQueries + * @covers Database::unionQueries */ public function testUnionQueries( $sql, $sqlText ) { $this->assertEquals( trim( $this->database->unionQueries( @@ -713,7 +713,7 @@ } /** - * @covers DatabaseBase::commit + * @covers Database::commit */ public function testTransactionCommit() { $this->database->begin( __METHOD__ ); @@ -722,7 +722,7 @@ } /** - * @covers DatabaseBase::rollback + * @covers Database::rollback */ public function testTransactionRollback() { $this->database->begin( __METHOD__ ); @@ -731,7 +731,7 @@ } /** - * @covers DatabaseBase::dropTable + * @covers Database::dropTable */ public function testDropTable() { $this->database->setExistingTables( [ 'table' ] ); @@ -740,7 +740,7 @@ } /** - * @covers DatabaseBase::dropTable + * @covers Database::dropTable */ public function testDropNonExistingTable() { $this->assertFalse( @@ -750,7 +750,7 @@ /** * @dataProvider provideMakeList - * @covers DatabaseBase::makeList + * @covers Database::makeList */ public function testMakeList( $list, $mode, $sqlText ) { $this->assertEquals( trim( $this->database->makeList( diff --git a/tests/phpunit/includes/db/DatabaseSqliteTest.php b/tests/phpunit/includes/db/DatabaseSqliteTest.php index 80fb826..172d686 100644 --- a/tests/phpunit/includes/db/DatabaseSqliteTest.php +++ b/tests/phpunit/includes/db/DatabaseSqliteTest.php @@ -7,7 +7,7 @@ $p['dbFilePath'] = ':memory:'; $p['schema'] = false; - return DatabaseBase::factory( 'SqliteMock', $p ); + return Database::factory( 'SqliteMock', $p ); } function query( $sql, $fname = '', $tempIgnore = false ) { diff --git a/tests/phpunit/includes/db/DatabaseTest.php b/tests/phpunit/includes/db/DatabaseTest.php index 48dc332..606a209 100644 --- a/tests/phpunit/includes/db/DatabaseTest.php +++ b/tests/phpunit/includes/db/DatabaseTest.php @@ -2,11 +2,11 @@ /** * @group Database - * @group DatabaseBase + * @group Database */ class DatabaseTest extends MediaWikiTestCase { /** - * @var DatabaseBase + * @var Database */ protected $db; @@ -27,7 +27,7 @@ } /** - * @covers DatabaseBase::dropTable + * @covers Database::dropTable */ public function testAddQuotesNull() { $check = "NULL"; @@ -266,7 +266,7 @@ } /** - * @covers DatabaseBase::setTransactionListener() + * @covers Database::setTransactionListener() */ public function testTransactionListener() { $db = $this->db; @@ -298,7 +298,7 @@ } /** - * @covers DatabaseBase::flushSnapshot() + * @covers Database::flushSnapshot() */ public function testFlushSnapshot() { $db = $this->db; @@ -350,9 +350,9 @@ } /** - * @covers DatabaseBase::getFlag( - * @covers DatabaseBase::setFlag() - * @covers DatabaseBase::restoreFlags() + * @covers Database::getFlag( + * @covers Database::setFlag() + * @covers Database::restoreFlags() */ public function testFlagSetting() { $db = $this->db; @@ -390,8 +390,8 @@ } /** - * @covers DatabaseBase::tablePrefix() - * @covers DatabaseBase::dbSchema() + * @covers Database::tablePrefix() + * @covers Database::dbSchema() */ public function testMutators() { $old = $this->db->tablePrefix(); diff --git a/tests/phpunit/includes/db/DatabaseTestHelper.php b/tests/phpunit/includes/db/DatabaseTestHelper.php index 31b692b..c5603c4 100644 --- a/tests/phpunit/includes/db/DatabaseTestHelper.php +++ b/tests/phpunit/includes/db/DatabaseTestHelper.php @@ -1,10 +1,10 @@ <?php /** - * Helper for testing the methods from the DatabaseBase class + * Helper for testing the methods from the Database class * @since 1.22 */ -class DatabaseTestHelper extends DatabaseBase { +class DatabaseTestHelper extends Database { /** * __CLASS__ of the test suite, @@ -14,7 +14,7 @@ /** * Array of lastSqls passed to query(), - * This is an array since some methods in DatabaseBase can do more than one + * This is an array since some methods in Database can do more than one * query. Cleared when calling getLastSqls(). */ protected $lastSqls = []; @@ -161,7 +161,7 @@ return false; } - function indexInfo( $table, $index, $fname = 'DatabaseBase::indexInfo' ) { + function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) { return false; } diff --git a/tests/phpunit/includes/db/LBFactoryTest.php b/tests/phpunit/includes/db/LBFactoryTest.php index d72768d..0f4484e 100644 --- a/tests/phpunit/includes/db/LBFactoryTest.php +++ b/tests/phpunit/includes/db/LBFactoryTest.php @@ -270,7 +270,7 @@ ); unset( $db ); - /** @var DatabaseBase $db */ + /** @var Database $db */ $db = $lb->getConnection( DB_MASTER, [], '' ); $lb->reuseConnection( $db ); // don't care @@ -322,7 +322,7 @@ $factory = $this->newLBFactoryMulti( [ 'localDomain' => $dbname ], [ 'dbname' => $dbname ] ); $lb = $factory->getMainLB(); - /** @var DatabaseBase $db */ + /** @var Database $db */ $db = $lb->getConnection( DB_MASTER, [], '' ); $lb->reuseConnection( $db ); // don't care diff --git a/tests/phpunit/includes/installer/DatabaseUpdaterTest.php b/tests/phpunit/includes/installer/DatabaseUpdaterTest.php index f01c47d..22d52f0 100644 --- a/tests/phpunit/includes/installer/DatabaseUpdaterTest.php +++ b/tests/phpunit/includes/installer/DatabaseUpdaterTest.php @@ -16,7 +16,7 @@ } } -class FakeDatabase extends DatabaseBase { +class FakeDatabase extends Database { public $lastInsertTable; public $lastInsertData; @@ -70,7 +70,7 @@ * member variables. * If no more rows are available, false is returned. * - * @param ResultWrapper|stdClass $res Object as returned from DatabaseBase::query(), etc. + * @param ResultWrapper|stdClass $res Object as returned from Database::query(), etc. * @return stdClass|bool * @throws DBUnexpectedError Thrown if the database returns an error */ @@ -83,7 +83,7 @@ * form. Fields are retrieved with $row['fieldname']. * If no more rows are available, false is returned. * - * @param ResultWrapper $res Result object as returned from DatabaseBase::query(), etc. + * @param ResultWrapper $res Result object as returned from Database::query(), etc. * @return array|bool * @throws DBUnexpectedError Thrown if the database returns an error */ diff --git a/tests/phpunit/includes/utils/BatchRowUpdateTest.php b/tests/phpunit/includes/utils/BatchRowUpdateTest.php index 560b6d2..ce6894e 100644 --- a/tests/phpunit/includes/utils/BatchRowUpdateTest.php +++ b/tests/phpunit/includes/utils/BatchRowUpdateTest.php @@ -129,7 +129,7 @@ $db = $this->mockDb(); $db->expects( $this->once() ) ->method( 'select' ) - // only testing second parameter of DatabaseBase::select + // only testing second parameter of Database::select ->with( 'some_table', $columns ) ->will( $this->returnValue( new ArrayIterator( [] ) ) ); @@ -164,7 +164,7 @@ /** * Slightly hackish to use reflection, but asserting different parameters - * to consecutive calls of DatabaseBase::select in phpunit is error prone + * to consecutive calls of Database::select in phpunit is error prone * * @dataProvider provider_readerSelectConditions */ @@ -214,7 +214,7 @@ protected function consecutivelyReturnFromSelect( array $results ) { $retvals = []; foreach ( $results as $rows ) { - // The DatabaseBase::select method returns iterators, so we do too. + // The Database::select method returns iterators, so we do too. $retvals[] = $this->returnValue( new ArrayIterator( $rows ) ); } @@ -235,8 +235,7 @@ } protected function mockDb() { - // Cant mock from DatabaseType or DatabaseBase, they dont - // have the full gamut of methods + // @TODO: mock from Database // FIXME: the constructor normally sets mAtomicLevels and mSrvCache $databaseMysql = $this->getMockBuilder( 'DatabaseMysql' ) ->disableOriginalConstructor() -- To view, visit https://gerrit.wikimedia.org/r/312945 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: Skizzerz <skizz...@skizzerz.net> Gerrit-Reviewer: TTO <at.li...@live.com.au> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits