Issue #2848821 by voleger, harsha012, vidhatanand, Sharique, alexpott, mondrake: Replace all calls to db_close, which is deprecated
parent
74c323ff09
commit
89bafb75b7
|
@ -456,6 +456,7 @@ function db_driver() {
|
|||
* @see \Drupal\Core\Database\Database::closeConnection()
|
||||
*/
|
||||
function db_close(array $options = []) {
|
||||
@trigger_error('db_close() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\Database::closeConnection() instead. See https://www.drupal.org/node/2993033.', E_USER_DEPRECATED);
|
||||
if (empty($options['target'])) {
|
||||
$options['target'] = NULL;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class Tasks extends InstallTasks {
|
|||
|
||||
// Close the database connection so that the configuration parameter
|
||||
// is applied to the current connection.
|
||||
db_close();
|
||||
Database::closeConnection();
|
||||
|
||||
// Recheck, if it fails, finally just rely on the end user to do the
|
||||
// right thing.
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace Drupal\KernelTests\Core\Database;
|
|||
|
||||
use Drupal\Core\Database\Transaction;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
/**
|
||||
* Deprecation tests cases for the database layer.
|
||||
*
|
||||
|
@ -65,4 +67,15 @@ class DatabaseLegacyTest extends DatabaseTestBase {
|
|||
$this->assertInstanceOf(Transaction::class, db_transaction());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the db_close() function.
|
||||
*
|
||||
* @expectedDeprecation db_close() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use \Drupal\Core\Database\Database::closeConnection() instead. See https://www.drupal.org/node/2993033.
|
||||
*/
|
||||
public function testDbClose() {
|
||||
$this->assertTrue(Database::isActiveConnection(), 'Database connection is active');
|
||||
db_close();
|
||||
$this->assertFalse(Database::isActiveConnection(), 'Database connection is not active');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue