mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 04:33:13 +01:00
Applying the field_exists() check to add and drop fields.
This commit is contained in:
parent
55b4d09637
commit
3e1861cc87
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user