Merge branch 'MDL-80098' of https://github.com/paulholden/moodle
This commit is contained in:
+1
-1
@@ -1220,7 +1220,7 @@ function blog_validate_access($courseid, $modid, $groupid, $entryid, $userid) {
|
||||
throw new \moodle_exception('courseblogdisable', 'blog');
|
||||
}
|
||||
if (!$mod = $DB->get_record('course_modules', array('id' => $modid))) {
|
||||
throw new \moodle_exception('invalidmoduleid', 'error', $modid);
|
||||
throw new \moodle_exception('invalidmoduleid', 'error', '', $modid);
|
||||
}
|
||||
$courseid = $mod->course;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class core_completion_generator extends component_generator_base {
|
||||
throw new moodle_exception('modulerequired');
|
||||
}
|
||||
if (!$DB->get_record('modules', ['id' => $record['module']])) {
|
||||
throw new moodle_exception('invalidmoduleid');
|
||||
throw new moodle_exception('invalidmoduleid', 'error', '', $record['module']);
|
||||
}
|
||||
|
||||
$record = (object) array_merge([
|
||||
|
||||
+1
-1
@@ -2848,7 +2848,7 @@ function get_course_and_cm_from_instance($instanceorid, $modulename, $courseorid
|
||||
$modinfo = get_fast_modinfo($course, $userid);
|
||||
$instances = $modinfo->get_instances_of($modulename);
|
||||
if (!array_key_exists($instanceid, $instances)) {
|
||||
throw new moodle_exception('invalidmoduleid', 'error', $instanceid);
|
||||
throw new moodle_exception('invalidmoduleid', 'error', '', $instanceid);
|
||||
}
|
||||
return array($course, $instances[$instanceid]);
|
||||
}
|
||||
|
||||
@@ -1001,6 +1001,14 @@ class modinfolib_test extends advanced_testcase {
|
||||
$this->assertInstanceOf('dml_exception', $e);
|
||||
}
|
||||
|
||||
// Invalid module ID.
|
||||
try {
|
||||
get_course_and_cm_from_instance(-1, 'page', $course);
|
||||
$this->fail();
|
||||
} catch (moodle_exception $e) {
|
||||
$this->assertStringContainsString('Invalid module ID: -1', $e->getMessage());
|
||||
}
|
||||
|
||||
// Invalid module name.
|
||||
try {
|
||||
get_course_and_cm_from_cmid($page->cmid, '1337 h4x0ring');
|
||||
|
||||
Reference in New Issue
Block a user