Issue #3049380 by voleger: Complete deprecation of _db_get_target() function

merge-requests/1119/head
Alex Pott 2019-05-28 11:54:33 +01:00
parent da11531a16
commit 3c5675d1b2
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 14 additions and 0 deletions

View File

@ -464,6 +464,7 @@ function db_close(array $options = []) {
* @see https://www.drupal.org/node/2993033
*/
function _db_get_target(array &$options, $allow_replica = TRUE) {
@trigger_error('_db_get_target() is deprecated in drupal:8.8.0. Will be removed before drupal:9.0.0. See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
if (empty($options['target']) || ($options['target'] === 'replica' && !$allow_replica)) {
$options['target'] = 'default';
}

View File

@ -530,4 +530,17 @@ class DatabaseLegacyTest extends DatabaseTestBase {
$this->assertTrue($session->has('ignore_replica_server'));
}
/**
* Tests the _db_get_target() function.
*
* @expectedDeprecation _db_get_target() is deprecated in drupal:8.8.0. Will be removed before drupal:9.0.0. See https://www.drupal.org/node/2993033
*/
public function testDbGetTarget() {
$op1 = $op2 = ['target' => 'replica'];
$this->assertEquals('replica', _db_get_target($op1));
$this->assertEquals('default', _db_get_target($op2, FALSE));
$this->assertEmpty($op1);
$this->assertEmpty($op2);
}
}