-
Bug
-
Resolution: Fixed
-
Minor
-
4.0
-
MOODLE_400_STABLE
-
MOODLE_400_STABLE
-
MDL-74407-master -
I maintain a contrib module, implemented as a block, that extends course navigation. I'm testing it against Moodle 4.0. This extension is based on a capability check. It is allowed for teachers by default, and may also be allowed for other roles such as students. This is the navigation code in question:
function block_clampmail_extend_navigation_course($navigation, $course, $context) {
|
if (has_capability('block/clampmail:cansend', $context)) { |
$url = new moodle_url('/blocks/clampmail/email.php', array('courseid' => $course->id)); |
$node = navigation_node::create(get_string('pluginname', 'block_clampmail'), $url, |
navigation_node::TYPE_SETTING, null, null, new pix_icon('i/email', get_string('pluginname', 'block_clampmail'))); |
$navigation->add_node($node);
|
}
|
}
|
With PHP 8.0, this works as expected, in that Quickmail is added to the course navigation for a student role, provided the student has been given the necessary capability. Under PHP 7.3 and PHP 7.4, the tests fail. I've confirmed manually that this is the case–the capability check passes, and the student can manually navigate to the correct location–the navigation item is not present.
To reproduce:
- Set up the https://github.com/moodlehq/moodle-docker environment with PHP 8.0 and https://github.com/CLAMP-IT/clampmail.
- Run the behat tests for @block_clampmail.
- Set up the https://github.com/moodlehq/moodle-docker environment with PHP 7.3 (or 7.4) and https://github.com/CLAMP-IT/clampmail.
- Run the behat tests for @block_clampmail.
I would expect the same results both times.