Commit 250e486b authored by webchick's avatar webchick

#363687 by chx: Simplify DBTNG codeflow.

parent cf43ce12
......@@ -1579,7 +1579,7 @@ function _registry_check_code($type, $name = NULL) {
// This function may get called when the default database is not active, but
// there is no reason we'd ever want to not use the default database for
// this query.
$file = Database::getConnection('default')->query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(
$file = Database::getConnection('default', 'default')->query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(
':name' => $name,
':type' => $type,
))
......
This diff is collapsed.
......@@ -133,7 +133,7 @@ function _dblog_get_message_types() {
* Note some values may be truncated for database column size restrictions.
*/
function dblog_watchdog(array $log_entry) {
Database::getConnection('default')->insert('watchdog')
Database::getConnection('default', 'default')->insert('watchdog')
->fields(array(
'uid' => $log_entry['user']->uid,
'type' => substr($log_entry['type'], 0, 64),
......
......@@ -819,7 +819,7 @@ protected function setUp() {
$clean_url_original = variable_get('clean_url', 0);
// Generate temporary prefixed database to ensure that tests have a clean starting point.
$db_prefix = Database::getActiveConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
$db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
include_once DRUPAL_ROOT . '/includes/install.inc';
drupal_install_system();
......
......@@ -522,7 +522,7 @@ function simpletest_clean_environment() {
* Removed prefixed tables from the database that are left over from crashed tests.
*/
function simpletest_clean_database() {
$tables = db_find_tables(Database::getActiveConnection()->prefixTables('{simpletest}') . '%');
$tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%');
$schema = drupal_get_schema_unprocessed('simpletest');
$ret = array();
foreach (array_diff_key($tables, $schema) as $table) {
......
......@@ -156,7 +156,7 @@ class DatabaseConnectionTestCase extends DatabaseTestCase {
Database::addConnectionInfo('default', 'slave', $connection_info['default']);
$db1 = Database::getConnection('default', 'default');
$db2 = Database::getConnection('default', 'slave');
$db2 = Database::getConnection('slave', 'default');
$this->assertNotNull($db1, t('default connection is a real connection object.'));
$this->assertNotNull($db2, t('slave connection is a real connection object.'));
......@@ -164,18 +164,18 @@ class DatabaseConnectionTestCase extends DatabaseTestCase {
// Try to open those targets another time, that should return the same objects.
$db1b = Database::getConnection('default', 'default');
$db2b = Database::getConnection('default', 'slave');
$db2b = Database::getConnection('slave', 'default');
$this->assertIdentical($db1, $db1b, t('A second call to getConnection() returns the same object.'));
$this->assertIdentical($db2, $db2b, t('A second call to getConnection() returns the same object.'));
// Try to open an unknown target.
$unknown_target = $this->randomName();
$db3 = Database::getConnection('default', $unknown_target);
$db3 = Database::getConnection($unknown_target, 'default');
$this->assertNotNull($db3, t('Opening an unknown target returns a real connection object.'));
$this->assertIdentical($db1, $db3, t('An unknown target opens the default connection.'));
// Try to open that unknown target another time, that should return the same object.
$db3b = Database::getConnection('default', $unknown_target);
$db3b = Database::getConnection($unknown_target, 'default');
$this->assertIdentical($db3, $db3b, t('A second call to getConnection() returns the same object.'));
}
......@@ -192,7 +192,7 @@ class DatabaseConnectionTestCase extends DatabaseTestCase {
Database::ignoreTarget('default', 'slave');
$db1 = Database::getConnection('default', 'default');
$db2 = Database::getConnection('default', 'slave');
$db2 = Database::getConnection('slave', 'default');
$this->assertIdentical($db1, $db2, t('Both targets refer to the same connection.'));
}
......@@ -2054,7 +2054,7 @@ class DatabaseInvalidDataTestCase extends DatabaseTestCase {
$name = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 63))->fetchField();
if ($name == 'Elvis') {
if (!Database::getActiveConnection()->supportsTransactions()) {
if (!Database::getConnection()->supportsTransactions()) {
// This is an expected fail.
// Database engines that don't support transactions can leave partial
// inserts in place when an error occurs. This is the case for MySQL
......@@ -2200,7 +2200,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
* Whether or not to try rolling back the transaction when we're done.
*/
protected function transactionOuterLayer($suffix, $rollback = FALSE) {
$connection = Database::getActiveConnection();
$connection = Database::getConnection();
$txn = db_transaction();
// Insert a single row into the testing table.
......@@ -2230,7 +2230,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
* Whether or not to try rolling back the transaction when we're done.
*/
protected function transactionInnerLayer($suffix, $rollback = FALSE) {
$connection = Database::getActiveConnection();
$connection = Database::getConnection();
// Start a transaction. If we're being called from ->transactionOuterLayer,
// then we're already in a transaction. Normally, that would make starting
......@@ -2263,7 +2263,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
*/
function testTransactionsSupported() {
try {
$connection = Database::getActiveConnection();
$connection = Database::getConnection();
if ($connection->supportsTransactions()) {
// Start a "required" transaction. This should fail if we do
......@@ -2284,7 +2284,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
*/
function testTransactionsNotSupported() {
try {
$connection = Database::getActiveConnection();
$connection = Database::getConnection();
if (!$connection->supportsTransactions()) {
// Start a "required" transaction. This should fail if we do this
......@@ -2306,7 +2306,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
*/
function testTransactionRollBackSupported() {
// This test won't work right if transactions are not supported.
if (!Database::getActiveConnection()->supportsTransactions()) {
if (!Database::getConnection()->supportsTransactions()) {
return;
}
try {
......@@ -2332,7 +2332,7 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
*/
function testTransactionRollBackNotSupported() {
// This test won't work right if transactions are supported.
if (Database::getActiveConnection()->supportsTransactions()) {
if (Database::getConnection()->supportsTransactions()) {
return;
}
try {
......
......@@ -24,7 +24,7 @@ class ModuleTestCase extends DrupalWebTestCase {
* specified base table. Defaults to TRUE.
*/
function assertTableCount($base_table, $count = TRUE) {
$tables = db_find_tables(Database::getActiveConnection()->prefixTables('{' . $base_table . '}') . '%');
$tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
if ($count) {
return $this->assertTrue($tables, t('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment