Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-74407

Course navigation for students renders inconsistently depending on PHP version

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.0
    • 4.0
    • Navigation
    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-74407-master
    • Hide

      Setup/Requirements:

      1. IMPORTANT - Webserver running php7.4
        1. Setup docker with 7.4 following the instructions in https://github.com/moodlehq/moodle-docker
        2. Use MOODLE_DOCKER_PHP_VERSION to set the php version
      2. Apply the patch sample.patch
      3. A course

      Testing

      1. Log in as admin
      2. Go to the course page
      3. Confirm you see the 'Example2.com' in the secondary navigation
      Show
      Setup/Requirements: IMPORTANT - Webserver running php7.4 Setup docker with 7.4 following the instructions in https://github.com/moodlehq/moodle-docker Use MOODLE_DOCKER_PHP_VERSION to set the php version Apply the patch sample.patch A course Testing Log in as admin Go to the course page Confirm you see the 'Example2.com' in the secondary navigation

    Description

      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:

      1. Set up the https://github.com/moodlehq/moodle-docker environment with PHP 8.0 and https://github.com/CLAMP-IT/clampmail.
      2. Run the behat tests for @block_clampmail.
      3. Set up the https://github.com/moodlehq/moodle-docker environment with PHP 7.3 (or 7.4) and https://github.com/CLAMP-IT/clampmail.
      4. Run the behat tests for @block_clampmail.

      I would expect the same results both times.

      Attachments

        1. php_74_result_1.png
          php_74_result_1.png
          284 kB
        2. php_74_result_2.png
          php_74_result_2.png
          159 kB
        3. php_80_result_1.png
          php_80_result_1.png
          313 kB
        4. php_80_result_2.png
          php_80_result_2.png
          164 kB
        5. php74-navigation.png
          php74-navigation.png
          8 kB
        6. php80-navigation.png
          php80-navigation.png
          9 kB
        7. sample.patch
          0.7 kB

        Activity

          People

            peterdias Peter Dias
            cfulton Charles Fulton
            Mihail Geshoski Mihail Geshoski
            Ilya Tregubov Ilya Tregubov
            Huong Nguyen Huong Nguyen
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              19/Apr/22

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours, 10 minutes
                5h 10m