diff --git a/CHANGES.md b/CHANGES.md index a35b35c..bd1030c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,10 @@ moodle-availability_cohort Changes ------- +### Unreleased + +* 2024-08-23 - Bugfix: Fix 'Invalid database query parameter value' exception when restoring course with 'Any cohort' restriction, thanks to mi-dave. + ### v4.1-r3 * 2024-08-11 - Add section for scheduled tasks to README diff --git a/classes/condition.php b/classes/condition.php index 031984c..0b370a6 100644 --- a/classes/condition.php +++ b/classes/condition.php @@ -212,7 +212,7 @@ public function include_after_restore($restoreid, $courseid, \base_logger $logge if ($DB->record_exists('cohort', ['id' => $this->cohortid]) && cohort_get_cohort($this->cohortid, \context_course::instance($courseid))) { $returnvalue = true; - } else if ($this->cohortid == 0 && !empty(cohort_get_cohorts(\context_course::instance($courseid)))) { + } else if ($this->cohortid == 0 && !empty(cohort_get_cohorts(\context_course::instance($courseid)->id))) { // The setting was set to any cohort and cohorts have not been deleted in the meantime. // Import the activity with the condition. $returnvalue = true; @@ -223,7 +223,7 @@ public function include_after_restore($restoreid, $courseid, \base_logger $logge } else { // We are not on the same instance. // We have to check if the setting was set to any cohort and cohorts exist on the new instance. - if ($this->cohortid == 0 && !empty(cohort_get_cohorts(\context_course::instance($courseid)))) { + if ($this->cohortid == 0 && !empty(cohort_get_cohorts(\context_course::instance($courseid)->id))) { $returnvalue = true; } else { // Availability was not set to any cohort, so do not include.