From 7fd019a9e71a33538593ae4993a8da5a0c38838b Mon Sep 17 00:00:00 2001 From: Tomo Tsuyuki Date: Mon, 16 Oct 2023 11:45:24 +1100 Subject: [PATCH] Issue #84 Throw exception for the empty new cmid --- classes/massactionutils.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/massactionutils.php b/classes/massactionutils.php index b4b0dde..d3f87b1 100644 --- a/classes/massactionutils.php +++ b/classes/massactionutils.php @@ -159,6 +159,9 @@ public static function duplicate_cm_to_course(object $course, object $cm): int { } } } + if (empty($newcmid)) { + throw new \moodle_exception('Could not duplicate course module from id ' . $cm->id); + } return $newcmid; } }