]> git.mjollnir.org Git - moodle.git/commitdiff
Applying the field_exists() check to add and drop fields.
authorstronk7 <stronk7>
Sat, 30 Sep 2006 15:48:23 +0000 (15:48 +0000)
committerstronk7 <stronk7>
Sat, 30 Sep 2006 15:48:23 +0000 (15:48 +0000)
lib/ddllib.php

index 417927d142f62921d549f4825a4f845676202b2b..3c4d3a52a7331339d2f5d62f38addc01bb1619bc 100644 (file)
@@ -595,6 +595,12 @@ function add_field($table, $field, $continue=true, $feedback=true) {
         return false;
     }
 
+/// Check the field doesn't exist
+    if (field_exists($table, $field)) {
+        debugging('Field ' . $field->getName() . ' exists. Skipping its creation', DEBUG_DEVELOPER);
+        return true;
+    }
+
     if(!$sqlarr = $table->getAddFieldSQL($CFG->dbtype, $CFG->prefix, $field, false)) {
         return true; //Empty array = nothing to do = no error
     }
@@ -625,6 +631,12 @@ function drop_field($table, $field, $continue=true, $feedback=true) {
         return false;
     }
 
+/// Check the field exists
+    if (!field_exists($table, $field)) {
+        debugging('Field ' . $field->getName() . ' do not exist. Skipping its deletion', DEBUG_DEVELOPER);
+        return true;
+    }
+
     if(!$sqlarr = $table->getDropFieldSQL($CFG->dbtype, $CFG->prefix, $field, false)) {
         return true; //Empty array = nothing to do = no error
     }