diff --git a/cohort/lib.php b/cohort/lib.php index 9a084eb63b720..7b398f3540473 100644 --- a/cohort/lib.php +++ b/cohort/lib.php @@ -71,8 +71,9 @@ function cohort_add_cohort($cohort) { */ function cohort_update_cohort($cohort) { global $DB; - if (isset($cohort->component) and empty($cohort->component)) { - $cohort->component = NULL; + if (property_exists($cohort, 'component') and empty($cohort->component)) { + // prevent NULLs + $cohort->component = ''; } $cohort->timemodified = time(); $DB->update_record('cohort', $cohort);