When clicking the "clean environment" button, I get:
user warning: Unknown table 'dev_dev_simpletest' query: DROP TABLE dev_dev_simpletest in drupal-6/includes/database.mysql-common.inc on line 261.
user warning: Unknown table 'dev_dev_simpletest_test_id' query: DROP TABLE dev_dev_simpletest_test_id in drupal-6/includes/database.mysql-common.inc on line 261.
/**
* Removed prefixed talbes from the database that are left over from crashed tests.
*/
function simpletest_clean_database() {
$tables = simpletest_get_like_tables(); // --> This returns the tables already prefixed.
$ret = array();
foreach ($tables as $table) {
db_drop_table($ret, $table); // --> the function expects un-prefixed table names!
}
Comments
Comment #1
beginner commentedAlso, i don't know if it's related, but my database has accumulated 300+ simpletest_* tables that have not been properly cleaned.
Comment #2
beginner commentedI am actually surprised that simpletest actually tries to drop {simpletest} and {simpletest_test_id}.
Is that the intended behavior?
Comment #3
beginner commentedI am not sure what's the intended behavior.
I fixed the issue for myself with the attached patch:
the tables {simpletest} and {simpletest_test_id} are kept, but the countless simpletest* tables have been removed.
I removed the $prefix from the SELECT query, and I don't use db_drop_table() which will add the unwanted prefix.
Comment #4
boombatower commentedThis is an issue with SimpleTest 7.x and should be fixed in core then backported.
Comment #5
boombatower commented1) The get like tables needs to return either non-prefixed tables, 2) the prefixes need to be removed from the table names before running drop command, or 3) the $db_prefix could be set to '' just before running drops.
Comment #6
Wesley Tanaka commentedsubscribing (for 6.x-2.x branch)
http://drupal.org/files/issues/table_prefix_simpletest.patch fixes this bug for me too.
Comment #7
damien tournoud commentedCore is not affected.
Comment #8
boombatower commentedI'm not following the problem here....can you give me detailed instructions on how to re-create.
simpletest_get_like_tables() should be looking for tables that were created with random prefix (ie. simpletest438928095)
and should return them as such.
Comment #9
beginner commentedSee the comments in the php code in comment #0 above.
Comment #10
boombatower commentedYes, and from reading that and patch I wasn't sure...as I think they are inconsistent.
Changing the drop to a manual query if it auto adds prefix makes sense...otherwise we could do
But I don't get why the get query would change.
$result = db_query("SELECT $select FROM information_schema.tables WHERE table_schema = '$database' AND table_name LIKE '$base_table%'");
That would seem to fry simpletest tables ONLY if the $db_prefix = ''; ?
Comment #11
Wesley Tanaka commentedThis no longer happens for me in simpletest 6.x-2.8, and the patch no longer applies, since the underlying code changed, so I am assuming that it is fixed.
Comment #13
westbywest commentedI'm running SimpleTest v 6.x-2.10 on D 6.12, and I get warnings in the status message box like these when I click the "Clean Environment" button after running tests.
Sure enough, see a bunch of tables in the DB with names like the following:
Arraysimpletest150449access
Arraysimpletest150449actions
Arraysimpletest150449actions_aid
Arraysimpletest150449authmap
Arraysimpletest150449batch
Arraysimpletest150449blocks
Arraysimpletest150449blocks_roles
HTML entity ' is an apostrophe, which presumably is being used in an attempt to escape table names.
Comment #14
westbywest commentedWhatever was causing the warnings described in the previous comment has now gone away on my site. I still see the word "Array" prepended to temporary DB table names for some reason, but it is not interfering with temp DB tables being creating and then deleted.
Comment #15
boombatower commentedThat is a different issue which is due to $db_prefix being an array and has been fixed.
Comment #16
kenorb commentedThe problem still exists, tested with dev version on 6.22.
Errors:
The prefix is added twice.
First part of #3 patch fixes the problem.
Comment #17
kenorb commentedFind the patch in the attachment.
Unfortunately I can't create a proper git patch passing the QA, I'm behind the proxy.
Comment #19
kenorb commentedVersion 6.x is no longer supported due to Drupal 6 End of Life.