From 42b9540e017e74cd80e1651887683051c89b1e4b Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sat, 27 Jan 2007 20:13:23 +0000 Subject: [PATCH] When renaming tables, check that the new one doesn't exist. --- lib/ddllib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/ddllib.php b/lib/ddllib.php index 34a168cb941f4..033df6a3c12b1 100644 --- a/lib/ddllib.php +++ b/lib/ddllib.php @@ -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);