From 197c9ecda138a7f4f012fa4c2a445c5f0efb8ff6 Mon Sep 17 00:00:00 2001 From: Tomo <54526084+TomoTsuyuki@users.noreply.github.com> Date: Fri, 12 Jan 2024 03:06:31 +1100 Subject: [PATCH] Issue #84 Throw exception for the empty new cmid (#91) --- 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; } }