Issue #2848808 by voleger, gaurav.kapoor, andypost, Vidushi Mehta, sidharthap: Replace all calls to db_find_tables, which is deprecated

8.7.x
Alex Pott 2018-09-18 13:20:17 +01:00
parent 383f701fe8
commit b083070276
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
5 changed files with 22 additions and 3 deletions

View File

@ -721,6 +721,10 @@ function db_field_exists($table, $field) {
* @see \Drupal\Core\Database\Schema::findTables()
*/
function db_find_tables($table_expression) {
@trigger_error(
'db_find_tables() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use $injected_database->schema()->findTables($table_expression) instead. See https://www.drupal.org/node/2993033',
E_USER_DEPRECATED
);
return Database::getConnection()->schema()->findTables($table_expression);
}

View File

@ -670,7 +670,7 @@ function simpletest_clean_environment() {
*/
function simpletest_clean_database() {
$schema = Database::getConnection()->schema();
$tables = db_find_tables('test%');
$tables = $schema->findTables('test%');
$count = 0;
foreach ($tables as $table) {
// Only drop tables which begin wih 'test' followed by digits, for example,

View File

@ -42,7 +42,8 @@ abstract class ModuleTestBase extends WebTestBase {
* specified base table. Defaults to TRUE.
*/
public function assertTableCount($base_table, $count = TRUE) {
$tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
$connection = Database::getConnection();
$tables = $connection->schema()->findTables($connection->prefixTables('{' . $base_table . '}') . '%');
if ($count) {
return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));

View File

@ -39,7 +39,8 @@ abstract class ModuleTestBase extends BrowserTestBase {
* specified base table. Defaults to TRUE.
*/
public function assertTableCount($base_table, $count = TRUE) {
$tables = db_find_tables(Database::getConnection()->prefixTables('{' . $base_table . '}') . '%');
$connection = Database::getConnection();
$tables = $connection->schema()->findTables($connection->prefixTables('{' . $base_table . '}') . '%');
if ($count) {
return $this->assertTrue($tables, format_string('Tables matching "@base_table" found.', ['@base_table' => $base_table]));

View File

@ -71,6 +71,19 @@ class DatabaseLegacyTest extends DatabaseTestBase {
$this->assertTrue(db_table_exists('test'));
}
/**
* Tests the db_find_tables() function.
*
* @expectedDeprecation db_find_tables() is deprecated in Drupal 8.0.x and will be removed before Drupal 9.0.0. Use $injected_database->schema()->findTables($table_expression) instead. See https://www.drupal.org/node/2993033
*/
public function testDbFindTables() {
$expected = [
'test_people' => 'test_people',
'test_people_copy' => 'test_people_copy',
];
$this->assertEquals($expected, db_find_tables('test_people%'));
}
/**
* Tests the db_set_active() function.
*