Skip to content

Commit

Permalink
Merge branch 'MDL-80098' of https://github.com/paulholden/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Jan 25, 2024
2 parents 854ba5d + e187e13 commit 32fe5a7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion blog/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion completion/tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function create_default_completion($record): stdClass {
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([
Expand Down
2 changes: 1 addition & 1 deletion lib/modinfolib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
8 changes: 8 additions & 0 deletions lib/tests/modinfolib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,14 @@ public function test_get_course_and_cm_from_instance() {
$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');
Expand Down

0 comments on commit 32fe5a7

Please sign in to comment.