Skip to content

Commit

Permalink
When renaming tables, check that the new one doesn't exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jan 27, 2007
1 parent d21a42d commit 42b9540
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ddllib.php
Original file line number Diff line number Diff line change
@@ -642,6 +642,13 @@ function rename_table($table, $newname, $continue=true, $feedback=true) {
return true; //Table doesn't exist, nothing to do
}

/// Check new table doesn't exist
$check = new XMLDBTable($newname);
if (table_exists($check)) {
debugging('Table ' . $check->getName() . ' already exists. Rename skipped', DEBUG_DEVELOPER);
return true; //Table exists, nothing to do
}

/// Check newname isn't empty
if (!$newname) {
debugging('New name for table ' . $index->getName() . ' is empty! Rename skipped', DEBUG_DEVELOPER);

0 comments on commit 42b9540

Please sign in to comment.