Skip to content

Commit

Permalink
MDL-21015 - prevent dead end under uncontrolled situations where clea…
Browse files Browse the repository at this point in the history
…nup doesn't happen on destruct
  • Loading branch information
stronk7 committed Dec 1, 2009
1 parent 56805c3 commit 04aa2fd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/simpletestlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,15 @@ public function __destruct() {
*/
protected function create_test_table($tablename, $installxmlfile) {
global $CFG;
$dbman = $this->testdb->get_manager();
if (isset($this->tables[$tablename])) {
debugging('You are attempting to create test table ' . $tablename . ' again. It already exists. Please review your code immediately.', DEBUG_DEVELOPER);
return;
}
$dbman = $this->testdb->get_manager();
if ($dbman->table_exists($tablename)) {
debugging('This table ' . $tablename . ' already exists from a previous execution. If the error persists you will need to review your code to ensure it is being created only once.', DEBUG_DEVELOPER);
$dbman->drop_table(new xmldb_table($tablename));
}
$dbman->install_one_table_from_xmldb_file($CFG->dirroot . '/' . $installxmlfile . '/db/install.xml', $tablename);
$this->tables[$tablename] = 1;
}
Expand Down

0 comments on commit 04aa2fd

Please sign in to comment.