diff --git a/core/includes/database.inc b/core/includes/database.inc index e7052b7bf3..e96a05ac01 100644 --- a/core/includes/database.inc +++ b/core/includes/database.inc @@ -637,7 +637,7 @@ function db_index_exists($table, $name) { * @return bool * TRUE if the given table exists, otherwise FALSE. * - * @deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get + * @deprecated as of Drupal 8.6.x, will be removed in Drupal 9.0.0. Instead, get * a database connection injected into your service from the container, get * its schema driver, and call tableExists() on it. For example, * $injected_database->schema()->tableExists($table); @@ -646,7 +646,7 @@ function db_index_exists($table, $name) { */ function db_table_exists($table) { @trigger_error( - "Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call tableExists() on it. For example, \$injected_database->schema()->tableExists(\$table);", + "Deprecated as of Drupal 8.6.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call tableExists() on it. For example, \$injected_database->schema()->tableExists(\$table);", E_USER_DEPRECATED ); return Database::getConnection()->schema()->tableExists($table); diff --git a/core/includes/schema.inc b/core/includes/schema.inc index c0b3a1a218..b3aae31558 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -5,6 +5,8 @@ * Schema API handling functions. */ +use Drupal\Core\Database\Database; + /** * @addtogroup schemaapi * @{ @@ -133,8 +135,9 @@ function drupal_uninstall_schema($module) { $schema = drupal_get_module_schema($module); _drupal_schema_initialize($schema, $module, FALSE); + $database_schema = Database::getConnection()->schema(); foreach ($schema as $table) { - db_drop_table($table['name']); + $database_schema->dropTable($table['name']); } } diff --git a/core/modules/system/src/Tests/Module/ModuleTestBase.php b/core/modules/system/src/Tests/Module/ModuleTestBase.php index c93a3284a4..2d96a2d197 100644 --- a/core/modules/system/src/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/src/Tests/Module/ModuleTestBase.php @@ -59,8 +59,9 @@ public function assertTableCount($base_table, $count = TRUE) { public function assertModuleTablesExist($module) { $tables = array_keys(drupal_get_module_schema($module)); $tables_exist = TRUE; + $schema = \Drupal::database()->schema(); foreach ($tables as $table) { - if (!(\Drupal::database()->schema()->tableExists($table))) { + if (!$schema->tableExists($table)) { $tables_exist = FALSE; } } @@ -76,8 +77,9 @@ public function assertModuleTablesExist($module) { public function assertModuleTablesDoNotExist($module) { $tables = array_keys(drupal_get_module_schema($module)); $tables_exist = FALSE; + $schema = \Drupal::database()->schema(); foreach ($tables as $table) { - if (\Drupal::database()->schema()->tableExists($table)) { + if ($schema->tableExists($table)) { $tables_exist = TRUE; } } diff --git a/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php b/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php index f240e38a6d..ad3faec788 100644 --- a/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php +++ b/core/modules/system/tests/src/Functional/Module/ModuleTestBase.php @@ -56,8 +56,9 @@ public function assertTableCount($base_table, $count = TRUE) { public function assertModuleTablesExist($module) { $tables = array_keys(drupal_get_module_schema($module)); $tables_exist = TRUE; + $schema = \Drupal::database()->schema(); foreach ($tables as $table) { - if (!(\Drupal::database()->schema()->tableExists($table))) { + if (!$schema->tableExists($table)) { $tables_exist = FALSE; } } @@ -73,8 +74,9 @@ public function assertModuleTablesExist($module) { public function assertModuleTablesDoNotExist($module) { $tables = array_keys(drupal_get_module_schema($module)); $tables_exist = FALSE; + $schema = \Drupal::database()->schema(); foreach ($tables as $table) { - if (\Drupal::database()->schema()->tableExists($table)) { + if ($schema->tableExists($table)) { $tables_exist = TRUE; } } diff --git a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php index f20b47c714..5519dcd9bc 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php @@ -39,7 +39,7 @@ public function testRegression_310447() { /** * Tests the db_table_exists() function. * - * @expectedDeprecation Deprecated as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call tableExists() on it. For example, $injected_database->schema()->tableExists($table); + * @expectedDeprecation Deprecated as of Drupal 8.6.x, will be removed in Drupal 9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call tableExists() on it. For example, $injected_database->schema()->tableExists($table); */ public function testDBTableExists() { $this->assertSame(TRUE, db_table_exists('test'), 'Returns true for existent table.'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php index 313169a783..12d4f148ea 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -380,8 +380,9 @@ public function testFieldUpdateFailure() { $this->tableMapping->getDedicatedDataTableName($prior_field_storage), $this->tableMapping->getDedicatedRevisionTableName($prior_field_storage), ]; + $schema = \Drupal::database()->schema(); foreach ($tables as $table_name) { - $this->assertTrue(\Drupal::database()->schema()->tableExists($table_name), t('Table %table exists.', ['%table' => $table_name])); + $this->assertTrue($schema->tableExists($table_name), t('Table %table exists.', ['%table' => $table_name])); } }