1 simpletest.module | simpletest_clean_database() |
Removed prefixed tables from the database that are left over from crashed tests.
File
- core/
modules/ simpletest/ simpletest.module, line 541 - Provides testing functionality.
Code
function simpletest_clean_database() {
$tables = db_find_tables(Database::getConnection()->prefixTables('{simpletest}') . '%');
$schema = backdrop_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_prefix}.
if (preg_match('/simpletest\d+.*/', $table, $matches)) {
db_drop_table($matches[0]);
$count++;
}
}
if ($count > 0) {
backdrop_set_message(format_plural($count, 'Removed 1 leftover table.', 'Removed @count leftover tables.'));
}
else {
backdrop_set_message(t('No leftover tables to remove.'));
}
}