/** @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) */
}
/**
- * @param DatabaseBase $connection
+ * @param Database $connection
* @throws MWException
*/
- private function reuseConnection( DatabaseBase $connection ) {
+ private function reuseConnection( Database $connection ) {
$this->loadBalancer->reuseConnection( $connection );
}
}
private function getWatchedItemsWithRCInfoQueryConds(
- DatabaseBase $db,
+ Database $db,
User $user,
array $options
) {
return $conds;
}
- private function getStartEndConds( DatabaseBase $db, array $options ) {
+ private function getStartEndConds( Database $db, array $options ) {
if ( !isset( $options['start'] ) && ! isset( $options['end'] ) ) {
return [];
}
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 [];
}
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;
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 ) );
);
}
- 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'] );
* 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(),
}
/**
- * @param DatabaseBase $connection
+ * @param Database $connection
*
* @throws MWException
*/
* 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 ) {
/**
* 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 ) {
/**
* 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 ) {
* 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
*
*
* @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 );
* 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__),
* @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
];
return function ( $index ) use ( $type, $params ) {
- return DatabaseBase::factory( $type, $params );
+ return Database::factory( $type, $params );
};
}
protected $archive;
- /** @var DatabaseBase */
+ /** @var IDatabase */
protected $db;
/**
/**
* 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;
}
try {
- $db = DatabaseBase::factory( 'mssql', [
+ $db = Database::factory( 'mssql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
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
}
try {
- DatabaseBase::factory( 'mssql', [
+ Database::factory( 'mssql', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
if ( !$status->isOK() ) {
return $status;
}
- /** @var DatabaseBase $conn */
+ /** @var Database $conn */
$conn = $status->value;
$dbName = $this->getVar( 'wgDBname' );
$schemaName = $this->getVar( 'wgDBmwschema' );
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' ),
if ( !$status->isOK() ) {
return false;
}
- /** @var $conn DatabaseBase */
+ /** @var $conn Database */
$conn = $status->value;
// Get current account name
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' ),
if ( !$status->isOK() ) {
return $status;
}
- /** @var DatabaseBase $conn */
+ /** @var Database $conn */
$conn = $status->value;
$dbName = $this->getVar( 'wgDBname' );
if ( !$conn->selectDB( $dbName ) ) {
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,
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,
'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,
/**
* 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
$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() );
# 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
} 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'." );
}
/**
* 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
*/
* Either a short hexidecimal string if a transaction is active or ""
*
* @var string
- * @see DatabaseBase::mTrxLevel
+ * @see Database::mTrxLevel
*/
protected $mTrxShortId = '';
/**
* 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 */
* 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;
/**
*/
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
*/
* @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 = '';
*
* @param array $options Associative array of options
* @return string
- * @see DatabaseBase::select()
+ * @see Database::select()
* @since 1.21
*/
protected function makeGroupByWithHaving( $options ) {
*
* @param array $options Associative array of options
* @return string
- * @see DatabaseBase::select()
+ * @see Database::select()
* @since 1.21
*/
protected function makeOrderBy( $options ) {
}
/**
- * Helper for DatabaseBase::insert().
+ * Helper for Database::insert().
*
* @param array $options
* @return string
}
/**
- * Make UPDATE options array for DatabaseBase::makeUpdateOptions
+ * Make UPDATE options array for Database::makeUpdateOptions
*
* @param array $options
* @return array
}
/**
- * 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 ) {
/**
* Issues the BEGIN command to the database server.
*
- * @see DatabaseBase::begin()
+ * @see Database::begin()
* @param string $fname
*/
protected function doBegin( $fname ) {
/**
* Issues the COMMIT command to the database server.
*
- * @see DatabaseBase::commit()
+ * @see Database::commit()
* @param string $fname
*/
protected function doCommit( $fname ) {
/**
* Issues the ROLLBACK command to the database server.
*
- * @see DatabaseBase::rollback()
+ * @see Database::rollback()
* @param string $fname
*/
protected function doRollback( $fname ) {
* 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.
$p['schema'] = false;
$p['tablePrefix'] = '';
- return DatabaseBase::factory( 'sqlite', $p );
+ return Database::factory( 'sqlite', $p );
}
/**
* 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
* 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
* 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().
*
* @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
*
* 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
<?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 */
* @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" .
}
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();
$failures = [];
$this->forEachOpenMasterConnection(
- function ( DatabaseBase $conn ) use ( $fname, &$failures ) {
+ function ( Database $conn ) use ( $fname, &$failures ) {
$conn->setTrxEndCallbackSuppression( true );
try {
$conn->flushSnapshot( $fname );
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
}
public function suppressTransactionEndCallbacks() {
- $this->forEachOpenMasterConnection( function ( DatabaseBase $conn ) {
+ $this->forEachOpenMasterConnection( function ( Database $conn ) {
$conn->setTrxEndCallbackSuppression( true );
} );
}
$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;
$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__ );
* 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 );
/**
* Our connection to the database
- * @var DatabaseBase
+ * @var Database
*/
private $db;
/**
* Primary database
*
- * @var DatabaseBase
+ * @var Database
* @since 1.18
*/
protected $db;
* 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 );
* @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;
}
}
// 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;
* 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() {
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;
/**
* 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 ) {
/**
* @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__ );
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();
* 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();
}
- // From interface DatabaseType
function insertId() {
}
/**
* @dataProvider provideSelect
- * @covers DatabaseBase::select
+ * @covers Database::select
*/
public function testSelect( $sql, $sqlText ) {
$this->database->select(
/**
* @dataProvider provideUpdate
- * @covers DatabaseBase::update
+ * @covers Database::update
*/
public function testUpdate( $sql, $sqlText ) {
$this->database->update(
/**
* @dataProvider provideDelete
- * @covers DatabaseBase::delete
+ * @covers Database::delete
*/
public function testDelete( $sql, $sqlText ) {
$this->database->delete(
/**
* @dataProvider provideUpsert
- * @covers DatabaseBase::upsert
+ * @covers Database::upsert
*/
public function testUpsert( $sql, $sqlText ) {
$this->database->upsert(
/**
* @dataProvider provideDeleteJoin
- * @covers DatabaseBase::deleteJoin
+ * @covers Database::deleteJoin
*/
public function testDeleteJoin( $sql, $sqlText ) {
$this->database->deleteJoin(
/**
* @dataProvider provideInsert
- * @covers DatabaseBase::insert
+ * @covers Database::insert
*/
public function testInsert( $sql, $sqlText ) {
$this->database->insert(
/**
* @dataProvider provideInsertSelect
- * @covers DatabaseBase::insertSelect
+ * @covers Database::insertSelect
*/
public function testInsertSelect( $sql, $sqlTextNative, $sqlSelect, $sqlInsert ) {
$this->database->insertSelect(
/**
* @dataProvider provideReplace
- * @covers DatabaseBase::replace
+ * @covers Database::replace
*/
public function testReplace( $sql, $sqlText ) {
$this->database->replace(
/**
* @dataProvider provideNativeReplace
- * @covers DatabaseBase::nativeReplace
+ * @covers Database::nativeReplace
*/
public function testNativeReplace( $sql, $sqlText ) {
$this->database->nativeReplace(
/**
* @dataProvider provideConditional
- * @covers DatabaseBase::conditional
+ * @covers Database::conditional
*/
public function testConditional( $sql, $sqlText ) {
$this->assertEquals( trim( $this->database->conditional(
/**
* @dataProvider provideBuildConcat
- * @covers DatabaseBase::buildConcat
+ * @covers Database::buildConcat
*/
public function testBuildConcat( $stringList, $sqlText ) {
$this->assertEquals( trim( $this->database->buildConcat(
/**
* @dataProvider provideBuildLike
- * @covers DatabaseBase::buildLike
+ * @covers Database::buildLike
*/
public function testBuildLike( $array, $sqlText ) {
$this->assertEquals( trim( $this->database->buildLike(
/**
* @dataProvider provideUnionQueries
- * @covers DatabaseBase::unionQueries
+ * @covers Database::unionQueries
*/
public function testUnionQueries( $sql, $sqlText ) {
$this->assertEquals( trim( $this->database->unionQueries(
}
/**
- * @covers DatabaseBase::commit
+ * @covers Database::commit
*/
public function testTransactionCommit() {
$this->database->begin( __METHOD__ );
}
/**
- * @covers DatabaseBase::rollback
+ * @covers Database::rollback
*/
public function testTransactionRollback() {
$this->database->begin( __METHOD__ );
}
/**
- * @covers DatabaseBase::dropTable
+ * @covers Database::dropTable
*/
public function testDropTable() {
$this->database->setExistingTables( [ 'table' ] );
}
/**
- * @covers DatabaseBase::dropTable
+ * @covers Database::dropTable
*/
public function testDropNonExistingTable() {
$this->assertFalse(
/**
* @dataProvider provideMakeList
- * @covers DatabaseBase::makeList
+ * @covers Database::makeList
*/
public function testMakeList( $list, $mode, $sqlText ) {
$this->assertEquals( trim( $this->database->makeList(
$p['dbFilePath'] = ':memory:';
$p['schema'] = false;
- return DatabaseBase::factory( 'SqliteMock', $p );
+ return Database::factory( 'SqliteMock', $p );
}
function query( $sql, $fname = '', $tempIgnore = false ) {
/**
* @group Database
- * @group DatabaseBase
+ * @group Database
*/
class DatabaseTest extends MediaWikiTestCase {
/**
- * @var DatabaseBase
+ * @var Database
*/
protected $db;
}
/**
- * @covers DatabaseBase::dropTable
+ * @covers Database::dropTable
*/
public function testAddQuotesNull() {
$check = "NULL";
}
/**
- * @covers DatabaseBase::setTransactionListener()
+ * @covers Database::setTransactionListener()
*/
public function testTransactionListener() {
$db = $this->db;
}
/**
- * @covers DatabaseBase::flushSnapshot()
+ * @covers Database::flushSnapshot()
*/
public function testFlushSnapshot() {
$db = $this->db;
}
/**
- * @covers DatabaseBase::getFlag(
- * @covers DatabaseBase::setFlag()
- * @covers DatabaseBase::restoreFlags()
+ * @covers Database::getFlag(
+ * @covers Database::setFlag()
+ * @covers Database::restoreFlags()
*/
public function testFlagSetting() {
$db = $this->db;
}
/**
- * @covers DatabaseBase::tablePrefix()
- * @covers DatabaseBase::dbSchema()
+ * @covers Database::tablePrefix()
+ * @covers Database::dbSchema()
*/
public function testMutators() {
$old = $this->db->tablePrefix();
<?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,
/**
* 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 = [];
return false;
}
- function indexInfo( $table, $index, $fname = 'DatabaseBase::indexInfo' ) {
+ function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
return false;
}
);
unset( $db );
- /** @var DatabaseBase $db */
+ /** @var Database $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
$lb->reuseConnection( $db ); // don't care
$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
}
}
-class FakeDatabase extends DatabaseBase {
+class FakeDatabase extends Database {
public $lastInsertTable;
public $lastInsertData;
* 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
*/
* 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
*/
$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( [] ) ) );
/**
* 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
*/
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 ) );
}
}
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()