]> git.mjollnir.org Git - moodle.git/commitdiff
When renaming tables, check that the new one doesn't exist.
authorstronk7 <stronk7>
Sat, 27 Jan 2007 20:13:23 +0000 (20:13 +0000)
committerstronk7 <stronk7>
Sat, 27 Jan 2007 20:13:23 +0000 (20:13 +0000)
lib/ddllib.php

index 34a168cb941f420d0381b9d3acbd0950004c39e9..033df6a3c12b183204c181aca055d403561f3812 100644 (file)
@@ -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);