Replace DatabaseBase:: with Database:: and update type hints
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 26 Sep 2016 22:40:07 +0000 (15:40 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 27 Sep 2016 04:20:03 +0000 (04:20 +0000)
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511

37 files changed:
includes/MergeHistory.php
includes/WatchedItemQueryService.php
includes/WatchedItemStore.php
includes/cache/LinkBatch.php
includes/changes/ChangesFeed.php
includes/changetags/ChangeTags.php
includes/dao/DBAccessBase.php
includes/db/DatabaseMssql.php
includes/filerepo/ForeignDBRepo.php
includes/filerepo/file/LocalFile.php
includes/installer/DatabaseUpdater.php
includes/installer/MssqlInstaller.php
includes/installer/MysqlInstaller.php
includes/installer/PostgresInstaller.php
includes/installer/SqliteInstaller.php
includes/libs/lockmanager/DBLockManager.php
includes/libs/rdbms/TransactionProfiler.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/DatabaseSqlite.php
includes/libs/rdbms/database/IDatabase.php
includes/libs/rdbms/encasing/LikeMatch.php
includes/libs/rdbms/exception/DBQueryError.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/objectcache/SqlBagOStuff.php
includes/page/WikiPage.php
includes/user/User.php
tests/parser/ParserTestRunner.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php
tests/phpunit/includes/db/DatabaseMysqlBaseTest.php
tests/phpunit/includes/db/DatabaseSQLTest.php
tests/phpunit/includes/db/DatabaseSqliteTest.php
tests/phpunit/includes/db/DatabaseTest.php
tests/phpunit/includes/db/DatabaseTestHelper.php
tests/phpunit/includes/db/LBFactoryTest.php
tests/phpunit/includes/installer/DatabaseUpdaterTest.php
tests/phpunit/includes/utils/BatchRowUpdateTest.php

index dd1fd37..f797fe3 100644 (file)
@@ -42,7 +42,7 @@ class MergeHistory {
        /** @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) */
index 4ac4dea..c040fb1 100644 (file)
@@ -63,10 +63,10 @@ class WatchedItemQueryService {
        }
 
        /**
-        * @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 @@ class WatchedItemQueryService {
        }
 
        private function getWatchedItemsWithRCInfoQueryConds(
-               DatabaseBase $db,
+               Database $db,
                User $user,
                array $options
        ) {
@@ -445,7 +445,7 @@ class WatchedItemQueryService {
                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 @@ class WatchedItemQueryService {
                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 @@ class WatchedItemQueryService {
                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 @@ class WatchedItemQueryService {
                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 @@ class WatchedItemQueryService {
                );
        }
 
-       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 @@ class WatchedItemQueryService {
         * 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(),
index 9a74401..478cc5f 100644 (file)
@@ -200,7 +200,7 @@ class WatchedItemStore implements StatsdAwareInterface {
        }
 
        /**
-        * @param DatabaseBase $connection
+        * @param Database $connection
         *
         * @throws MWException
         */
index 8a4d061..d773fff 100644 (file)
@@ -236,7 +236,7 @@ class LinkBatch {
         * 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 ) {
index ca6ba48..15a00c7 100644 (file)
@@ -164,7 +164,7 @@ class ChangesFeed {
 
        /**
         * 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 @@ class ChangesFeed {
 
        /**
         * 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 ) {
index 6455a3a..955e972 100644 (file)
@@ -608,10 +608,10 @@ class ChangeTags {
         * 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
         *
index 01814c1..ed617fe 100644 (file)
@@ -68,9 +68,9 @@ abstract class DBAccessBase implements IDBAccessObject {
         *
         * @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 );
index eb061d8..45ea54c 100644 (file)
@@ -737,15 +737,15 @@ class DatabaseMssql extends DatabaseBase {
         * 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 @@ class DatabaseMssql extends DatabaseBase {
         * @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
index 001800f..be046bd 100644 (file)
@@ -106,7 +106,7 @@ class ForeignDBRepo extends LocalRepo {
                ];
 
                return function ( $index ) use ( $type, $params ) {
-                       return DatabaseBase::factory( $type, $params );
+                       return Database::factory( $type, $params );
                };
        }
 
index 60cfdac..7ffb147 100644 (file)
@@ -2852,7 +2852,7 @@ class LocalFileMoveBatch {
 
        protected $archive;
 
-       /** @var DatabaseBase */
+       /** @var IDatabase */
        protected $db;
 
        /**
index 2425005..fbdc934 100644 (file)
@@ -101,11 +101,11 @@ abstract class DatabaseUpdater {
        /**
         * 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;
index 62cd883..739be82 100644 (file)
@@ -212,7 +212,7 @@ class MssqlInstaller extends DatabaseInstaller {
                }
 
                try {
-                       $db = DatabaseBase::factory( 'mssql', [
+                       $db = Database::factory( 'mssql', [
                                'host' => $this->getVar( 'wgDBserver' ),
                                'user' => $user,
                                'password' => $password,
@@ -261,7 +261,7 @@ class MssqlInstaller extends DatabaseInstaller {
                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 @@ class MssqlInstaller extends DatabaseInstaller {
                        }
 
                        try {
-                               DatabaseBase::factory( 'mssql', [
+                               Database::factory( 'mssql', [
                                        'host' => $this->getVar( 'wgDBserver' ),
                                        'user' => $user,
                                        'password' => $password,
@@ -491,7 +491,7 @@ class MssqlInstaller extends DatabaseInstaller {
                if ( !$status->isOK() ) {
                        return $status;
                }
-               /** @var DatabaseBase $conn */
+               /** @var Database $conn */
                $conn = $status->value;
                $dbName = $this->getVar( 'wgDBname' );
                $schemaName = $this->getVar( 'wgDBmwschema' );
index 1bd3f51..812742c 100644 (file)
@@ -143,7 +143,7 @@ class MysqlInstaller extends DatabaseInstaller {
        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 @@ class MysqlInstaller extends DatabaseInstaller {
                if ( !$status->isOK() ) {
                        return false;
                }
-               /** @var $conn DatabaseBase */
+               /** @var $conn Database */
                $conn = $status->value;
 
                // Get current account name
@@ -427,7 +427,7 @@ class MysqlInstaller extends DatabaseInstaller {
                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 @@ class MysqlInstaller extends DatabaseInstaller {
                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 @@ class MysqlInstaller extends DatabaseInstaller {
                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,
index 0728415..7a2794d 100644 (file)
@@ -154,7 +154,7 @@ class PostgresInstaller extends DatabaseInstaller {
        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 @@ class PostgresInstaller extends DatabaseInstaller {
                                        '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 @@ class PostgresInstaller extends DatabaseInstaller {
 
        /**
         * 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
index 0adeddf..c5c4a7c 100644 (file)
@@ -184,7 +184,7 @@ class SqliteInstaller extends DatabaseInstaller {
                $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 @@ class SqliteInstaller extends DatabaseInstaller {
 
                # 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
index b058146..64a2916 100644 (file)
@@ -148,7 +148,7 @@ abstract class DBLockManager extends QuorumLockManager {
                        } 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'." );
                        }
index 5c9976d..4d2b28f 100644 (file)
@@ -29,7 +29,7 @@ use Psr\Log\NullLogger;
 /**
  * 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
  */
index 897e55f..2b058e9 100644 (file)
@@ -128,7 +128,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         * 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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         * 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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         * 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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         */
        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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         * @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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         *
         * @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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         *
         * @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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        }
 
        /**
-        * Helper for DatabaseBase::insert().
+        * Helper for Database::insert().
         *
         * @param array $options
         * @return string
@@ -1482,7 +1482,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        }
 
        /**
-        * Make UPDATE options array for DatabaseBase::makeUpdateOptions
+        * Make UPDATE options array for Database::makeUpdateOptions
         *
         * @param array $options
         * @return array
@@ -1502,9 +1502,9 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        }
 
        /**
-        * 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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        /**
         * 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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        /**
         * 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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
        /**
         * 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 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         * 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.
index c33d3b3..156e525 100644 (file)
@@ -117,7 +117,7 @@ class DatabaseSqlite extends DatabaseBase {
                $p['schema'] = false;
                $p['tablePrefix'] = '';
 
-               return DatabaseBase::factory( 'sqlite', $p );
+               return Database::factory( 'sqlite', $p );
        }
 
        /**
index 0396ec8..c32a7ff 100644 (file)
@@ -613,7 +613,7 @@ interface IDatabase {
         * 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 @@ interface IDatabase {
         *     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 @@ interface IDatabase {
         * 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 @@ interface IDatabase {
         *
         * @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 @@ interface IDatabase {
         *
         * 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
index 5dee884..b0b3c87 100644 (file)
@@ -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 */
index ac9217d..002d253 100644 (file)
@@ -40,7 +40,7 @@ class DBQueryError extends DBExpectedError {
         * @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" .
index 36e4c6c..a60e741 100644 (file)
@@ -1024,7 +1024,7 @@ class LoadBalancer implements ILoadBalancer {
        }
 
        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 @@ class LoadBalancer implements ILoadBalancer {
 
                $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 @@ class LoadBalancer implements ILoadBalancer {
 
        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 @@ class LoadBalancer implements ILoadBalancer {
        }
 
        public function suppressTransactionEndCallbacks() {
-               $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) {
+               $this->forEachOpenMasterConnection( function ( Database $conn ) {
                        $conn->setTrxEndCallbackSuppression( true );
                } );
        }
index d06213f..47dae78 100644 (file)
@@ -182,7 +182,7 @@ class SqlBagOStuff extends BagOStuff {
                                $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;
index 50c5030..41e9e4f 100644 (file)
@@ -3502,7 +3502,7 @@ class WikiPage implements Page, IDBAccessObject {
                $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__ );
index 0d06c7b..6083db9 100644 (file)
@@ -1434,11 +1434,11 @@ class User implements IDBAccessObject {
         * 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 );
index d2968a1..369cd0e 100644 (file)
@@ -49,7 +49,7 @@ class ParserTestRunner {
 
        /**
         * Our connection to the database
-        * @var DatabaseBase
+        * @var Database
         */
        private $db;
 
index c952229..45a7ce5 100644 (file)
@@ -42,7 +42,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        /**
         * Primary database
         *
-        * @var DatabaseBase
+        * @var Database
         * @since 1.18
         */
        protected $db;
@@ -1070,11 +1070,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         * 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 @@ 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 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 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                }
 
                // 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 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
         * 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 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                        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 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        /**
         * 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 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        /**
         * @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__ );
 
index 1d232fe..93e0b57 100644 (file)
@@ -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();
 
index c014e84..dbb126f 100644 (file)
@@ -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 @@ class FakeDatabaseMysqlBase extends DatabaseMysqlBase {
 
        }
 
-       // From interface DatabaseType
        function insertId() {
        }
 
index 68bc964..656e661 100644 (file)
@@ -26,7 +26,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideSelect
-        * @covers DatabaseBase::select
+        * @covers Database::select
         */
        public function testSelect( $sql, $sqlText ) {
                $this->database->select(
@@ -132,7 +132,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideUpdate
-        * @covers DatabaseBase::update
+        * @covers Database::update
         */
        public function testUpdate( $sql, $sqlText ) {
                $this->database->update(
@@ -184,7 +184,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideDelete
-        * @covers DatabaseBase::delete
+        * @covers Database::delete
         */
        public function testDelete( $sql, $sqlText ) {
                $this->database->delete(
@@ -217,7 +217,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideUpsert
-        * @covers DatabaseBase::upsert
+        * @covers Database::upsert
         */
        public function testUpsert( $sql, $sqlText ) {
                $this->database->upsert(
@@ -253,7 +253,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideDeleteJoin
-        * @covers DatabaseBase::deleteJoin
+        * @covers Database::deleteJoin
         */
        public function testDeleteJoin( $sql, $sqlText ) {
                $this->database->deleteJoin(
@@ -300,7 +300,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideInsert
-        * @covers DatabaseBase::insert
+        * @covers Database::insert
         */
        public function testInsert( $sql, $sqlText ) {
                $this->database->insert(
@@ -353,7 +353,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideInsertSelect
-        * @covers DatabaseBase::insertSelect
+        * @covers Database::insertSelect
         */
        public function testInsertSelect( $sql, $sqlTextNative, $sqlSelect, $sqlInsert ) {
                $this->database->insertSelect(
@@ -440,7 +440,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideReplace
-        * @covers DatabaseBase::replace
+        * @covers Database::replace
         */
        public function testReplace( $sql, $sqlText ) {
                $this->database->replace(
@@ -555,7 +555,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideNativeReplace
-        * @covers DatabaseBase::nativeReplace
+        * @covers Database::nativeReplace
         */
        public function testNativeReplace( $sql, $sqlText ) {
                $this->database->nativeReplace(
@@ -582,7 +582,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideConditional
-        * @covers DatabaseBase::conditional
+        * @covers Database::conditional
         */
        public function testConditional( $sql, $sqlText ) {
                $this->assertEquals( trim( $this->database->conditional(
@@ -623,7 +623,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideBuildConcat
-        * @covers DatabaseBase::buildConcat
+        * @covers Database::buildConcat
         */
        public function testBuildConcat( $stringList, $sqlText ) {
                $this->assertEquals( trim( $this->database->buildConcat(
@@ -646,7 +646,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideBuildLike
-        * @covers DatabaseBase::buildLike
+        * @covers Database::buildLike
         */
        public function testBuildLike( $array, $sqlText ) {
                $this->assertEquals( trim( $this->database->buildLike(
@@ -677,7 +677,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideUnionQueries
-        * @covers DatabaseBase::unionQueries
+        * @covers Database::unionQueries
         */
        public function testUnionQueries( $sql, $sqlText ) {
                $this->assertEquals( trim( $this->database->unionQueries(
@@ -713,7 +713,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::commit
+        * @covers Database::commit
         */
        public function testTransactionCommit() {
                $this->database->begin( __METHOD__ );
@@ -722,7 +722,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::rollback
+        * @covers Database::rollback
         */
        public function testTransactionRollback() {
                $this->database->begin( __METHOD__ );
@@ -731,7 +731,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::dropTable
+        * @covers Database::dropTable
         */
        public function testDropTable() {
                $this->database->setExistingTables( [ 'table' ] );
@@ -740,7 +740,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::dropTable
+        * @covers Database::dropTable
         */
        public function testDropNonExistingTable() {
                $this->assertFalse(
@@ -750,7 +750,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
 
        /**
         * @dataProvider provideMakeList
-        * @covers DatabaseBase::makeList
+        * @covers Database::makeList
         */
        public function testMakeList( $list, $mode, $sqlText ) {
                $this->assertEquals( trim( $this->database->makeList(
index 80fb826..172d686 100644 (file)
@@ -7,7 +7,7 @@ class DatabaseSqliteMock extends DatabaseSqlite {
                $p['dbFilePath'] = ':memory:';
                $p['schema'] = false;
 
-               return DatabaseBase::factory( 'SqliteMock', $p );
+               return Database::factory( 'SqliteMock', $p );
        }
 
        function query( $sql, $fname = '', $tempIgnore = false ) {
index 48dc332..606a209 100644 (file)
@@ -2,11 +2,11 @@
 
 /**
  * @group Database
- * @group DatabaseBase
+ * @group Database
  */
 class DatabaseTest extends MediaWikiTestCase {
        /**
-        * @var DatabaseBase
+        * @var Database
         */
        protected $db;
 
@@ -27,7 +27,7 @@ class DatabaseTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::dropTable
+        * @covers Database::dropTable
         */
        public function testAddQuotesNull() {
                $check = "NULL";
@@ -266,7 +266,7 @@ class DatabaseTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::setTransactionListener()
+        * @covers Database::setTransactionListener()
         */
        public function testTransactionListener() {
                $db = $this->db;
@@ -298,7 +298,7 @@ class DatabaseTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::flushSnapshot()
+        * @covers Database::flushSnapshot()
         */
        public function testFlushSnapshot() {
                $db = $this->db;
@@ -350,9 +350,9 @@ class DatabaseTest extends MediaWikiTestCase {
        }
 
        /**
-        * @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 @@ class DatabaseTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers DatabaseBase::tablePrefix()
-        * @covers DatabaseBase::dbSchema()
+        * @covers Database::tablePrefix()
+        * @covers Database::dbSchema()
         */
        public function testMutators() {
                $old = $this->db->tablePrefix();
index 31b692b..c5603c4 100644 (file)
@@ -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 @@ class DatabaseTestHelper extends DatabaseBase {
 
        /**
         * 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 @@ class DatabaseTestHelper extends DatabaseBase {
                return false;
        }
 
-       function indexInfo( $table, $index, $fname = 'DatabaseBase::indexInfo' ) {
+       function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
                return false;
        }
 
index d72768d..0f4484e 100644 (file)
@@ -270,7 +270,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                );
                unset( $db );
 
-               /** @var DatabaseBase $db */
+               /** @var Database $db */
                $db = $lb->getConnection( DB_MASTER, [], '' );
                $lb->reuseConnection( $db ); // don't care
 
@@ -322,7 +322,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                $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
 
index f01c47d..22d52f0 100644 (file)
@@ -16,7 +16,7 @@ class DatabaseUpdaterTest extends MediaWikiTestCase {
        }
 }
 
-class FakeDatabase extends DatabaseBase {
+class FakeDatabase extends Database {
        public $lastInsertTable;
        public $lastInsertData;
 
@@ -70,7 +70,7 @@ class FakeDatabase extends DatabaseBase {
         * 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 @@ class FakeDatabase extends DatabaseBase {
         * 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
         */
index 560b6d2..ce6894e 100644 (file)
@@ -129,7 +129,7 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
                $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 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
 
        /**
         * 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 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
        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 @@ class BatchRowUpdateTest extends MediaWikiTestCase {
        }
 
        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()