MDL-74900 core_course: Exception in module deletion if missing instance

This commit is contained in:
raortegar
2025-05-21 08:27:23 +02:00
parent 328810e933
commit bfdcf4b490
+5
View File
@@ -763,6 +763,11 @@ function course_delete_module($cmid, $async = false) {
}
}
if (empty($cm->instance)) {
throw new moodle_exception('cannotdeletemodulemissinginstance', '', '', null,
"Cannot delete course module with ID $cm->id because it does not have a valid activity instance.");
}
// Call the delete_instance function, if it returns false throw an exception.
if (!$deleteinstancefunction($cm->instance)) {
throw new moodle_exception('cannotdeletemoduleinstance', '', '', null,