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

local_pluginname_extends_navigation() fatal error if it tries to access $PAGE->settingsnav on mod/quiz/edit.php

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a bug
    • Icon: Minor Minor
    • None
    • 2.4, 2.5, 2.6
    • Navigation, Quiz
    • MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE

      A local plugin can create a function in it's lib.php to extend the navigation.

      If this function tries to access $PAGE->settingsnav when viewing mod/quiz/edit.php, a fatal error happens with the message "Undefined property: moodle_page::$settingsnav"

      I'm not quite sure what the right way to fix this is. Perhaps quiz_extend_settings_navigation() should be used instead of the current code in mod/quiz/edit.php:

      $node = $PAGE->settingsnav->find('mod_quiz_edit', navigation_node::TYPE_SETTING);
      if ($node) {
          $node->make_active();
      }
      

      Alternatively, lib/navigationlib.php could call load_local_plugin_settings after it marks itself as initialised:

      diff --git a/lib/navigationlib.php b/lib/navigationlib.php
      index d37f406..f5ea55b 100644
      --- a/lib/navigationlib.php
      +++ b/lib/navigationlib.php
      @@ -3301,15 +3301,15 @@ class settings_navigation extends navigation_node {
                   $this->add(get_string('returntooriginaluser', 'moodle', fullname($realuser, true)), $url, self::TYPE_SETTING, null, null, new pix_icon('t/left', ''));
               }
       
      -        // At this point we give any local plugins the ability to extend/tinker with the navigation settings.
      -        $this->load_local_plugin_settings();
      -
               foreach ($this->children as $key=>$node) {
                   if ($node->nodetype != self::NODETYPE_BRANCH || $node->children->count()===0) {
                       $node->remove();
                   }
               }
               $this->initialised = true;
      +
      +        // At this point we give any local plugins the ability to extend/tinker with the navigation settings.
      +        $this->load_local_plugin_settings();
           }
           /**
            * Override the parent function so that we can add preceeding hr's and set a
      

            Unassigned Unassigned
            brianking Brian King
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.