diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php index ca66143..bea803b 100644 --- a/core/modules/simpletest/drupal_web_test_case.php +++ b/core/modules/simpletest/drupal_web_test_case.php @@ -1459,10 +1459,9 @@ class DrupalWebTestCase extends DrupalTestCase { // Delete temporary files directory. file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10)); - // Remove all prefixed tables (all the tables in the schema). - $schema = drupal_get_schema(NULL, TRUE); - foreach ($schema as $name => $table) { - db_drop_table($name); + // Remove all prefixed tables. + foreach (db_find_tables('%' . $this->databasePrefix . '%') as $table) { + db_drop_table(preg_replace('/^.*' . $this->databasePrefix . '(.*)$/', '$1', $table)); } // Get back to the original connection. diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index eb33d1b..c71ee8a 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -428,13 +428,12 @@ 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::getConnection()->prefixTables('{simpletest}') . '%'); - $schema = drupal_get_schema_unprocessed('simpletest'); $count = 0; - foreach (array_diff_key($tables, $schema) as $table) { - // Strip the prefix and skip tables without digits following "simpletest", - // e.g. {simpletest_test_id}. + foreach (db_find_tables('%simpletest%') as $table) { if (preg_match('/simpletest\d+.*/', $table, $matches)) { + // The table names returned by db_find_tables() are prefixed. If we don't + // strip the prefix, we end up with 'prefix_prefix_tablename' queries in + // db_drop_table(). Hence we use $matches[0] instead of $table. db_drop_table($matches[0]); $count++; }