Skip to content

Commit

Permalink
Fix 'Invalid database query parameter value' exception when restoring…
Browse files Browse the repository at this point in the history
… course with 'Any cohort' restriction
  • Loading branch information
mi-dave authored Jul 25, 2024
1 parent e70b8ff commit d7a2ec8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions classes/condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand Down

0 comments on commit d7a2ec8

Please sign in to comment.