Moodle
  1. Moodle
  2. MDL-39127

Fatal error caused by navbar renderer

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.4.4, 2.5
    • Component/s: Navigation
    • Labels:
    • Testing Instructions:
      Hide
      1. Log in as a admin.
      2. Ensure $CFG->navshowcategories is enabled.
      3. Log in as a student.
      4. Browse to a course.
      5. Check the category path for the course is shown in the navbar.
      6. Log in as an admin and disable $CFG->navshowcategories.
      7. Log in as a student.
      8. Browse to the same course.
      9. Check that the category path is no longer shown.
      Show
      Log in as a admin. Ensure $CFG->navshowcategories is enabled. Log in as a student. Browse to a course. Check the category path for the course is shown in the navbar. Log in as an admin and disable $CFG->navshowcategories. Log in as a student. Browse to the same course. Check that the category path is no longer shown.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull Master Branch:
      wip-MDL-39127-m25-integration
    • Rank:
      49722

      Description

      When going to any course in the simple theme, I get this problem:

      Coding error detected, it must be fixed by a programmer: PHP catchable fatal error
      Debug info: Argument 1 passed to renderer_base::render() must implement interface renderable, instance of stdClass given, called in [dirroot]/theme/bootstrap/renderers/core.php on line 58 and defined
      Error code: codingerror
      Stack trace:
      line 406 of /lib/setuplib.php: coding_exception thrown
      line 98 of /lib/outputrenderers.php: call to default_error_handler()
      line 58 of /theme/bootstrap/renderers/core.php: call to renderer_base->render()
      line 122 of /theme/simple/layout/general.php: call to theme_bootstrap_core_renderer->navbar()
      line 841 of /lib/outputrenderers.php: call to include()
      line 771 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
      line 240 of /course/view.php: call to core_renderer->header()
      

      It seems one of the items returned == false.

        Issue Links

          Activity

          Hide
          Dan Poltawski added a comment -

          What I don't know is what is going on and causing this problem. I fixed it with this patch:

          diff --git a/theme/bootstrap/renderers/core.php b/theme/bootstrap/renderers/core.php
          index 203826b..120bb44 100644
          --- a/theme/bootstrap/renderers/core.php
          +++ b/theme/bootstrap/renderers/core.php
          @@ -53,9 +53,12 @@ class theme_bootstrap_core_renderer extends core_renderer {
                */
               public function navbar() {
                   $items = $this->page->navbar->get_items();
          +        $breadcrumbs = array();
                   foreach ($items as $item) {
          -            $item->hideicon = true;
          +            if ($item) {
          +                $item->hideicon = true;
                           $breadcrumbs[] = $this->render($item);
          +            }
                   }
                   $divider = '<span class="divider">/</span>';
          
          Show
          Dan Poltawski added a comment - What I don't know is what is going on and causing this problem. I fixed it with this patch: diff --git a/theme/bootstrap/renderers/core.php b/theme/bootstrap/renderers/core.php index 203826b..120bb44 100644 --- a/theme/bootstrap/renderers/core.php +++ b/theme/bootstrap/renderers/core.php @@ -53,9 +53,12 @@ class theme_bootstrap_core_renderer extends core_renderer { */ public function navbar() { $items = $ this ->page->navbar->get_items(); + $breadcrumbs = array(); foreach ($items as $item) { - $item->hideicon = true ; + if ($item) { + $item->hideicon = true ; $breadcrumbs[] = $ this ->render($item); + } } $divider = '<span class= "divider" >/</span>';
          Hide
          Dan Poltawski added a comment -

          Turns out this is nothing to do with bootrap:

          ( ! ) Warning: Creating default object from empty value in /Users/danp/git/integration/lib/outputrenderers.php on line 2646
          Call Stack

          1. Time Memory Function Location
            1 0.0010 327824 {main}

            ( ) ../view.php:0
            2 0.4608 25638032 core_renderer->header( ) ../view.php:240
            3 0.4837 26979760 core_renderer->render_page_layout( ) ../outputrenderers.php:771
            4 0.4848 27034968 include( '/Users/danp/git/integration/theme/base/layout/general.php' ) ../outputrenderers.php:841
            5 2.7458 62830624 core_renderer->navbar( ) ../general.php:77
            Coding error detected, it must be fixed by a programmer: PHP catchable fatal error
            Debug info: Argument 1 passed to renderer_base::render() must implement interface renderable, instance of stdClass given, called in [dirroot]/lib/outputrenderers.php on line 2650 and defined
            Error code: codingerror
            Stack trace:
            line 406 of /lib/setuplib.php: coding_exception thrownline 98 of /lib/outputrenderers.php: call to default_error_handler()line 2650 of /lib/outputrenderers.php: call to renderer_base->render()line 77 of /theme/base/layout/general.php: call to core_renderer->navbar()line 841 of /lib/outputrenderers.php: call to include()line 771 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()line 240 of /course/view.php: call to core_renderer->header()

          Show
          Dan Poltawski added a comment - Turns out this is nothing to do with bootrap: ( ! ) Warning: Creating default object from empty value in /Users/danp/git/integration/lib/outputrenderers.php on line 2646 Call Stack Time Memory Function Location 1 0.0010 327824 {main} ( ) ../view.php:0 2 0.4608 25638032 core_renderer->header( ) ../view.php:240 3 0.4837 26979760 core_renderer->render_page_layout( ) ../outputrenderers.php:771 4 0.4848 27034968 include( '/Users/danp/git/integration/theme/base/layout/general.php' ) ../outputrenderers.php:841 5 2.7458 62830624 core_renderer->navbar( ) ../general.php:77 Coding error detected, it must be fixed by a programmer: PHP catchable fatal error Debug info: Argument 1 passed to renderer_base::render() must implement interface renderable, instance of stdClass given, called in [dirroot] /lib/outputrenderers.php on line 2650 and defined Error code: codingerror Stack trace: line 406 of /lib/setuplib.php: coding_exception thrownline 98 of /lib/outputrenderers.php: call to default_error_handler()line 2650 of /lib/outputrenderers.php: call to renderer_base->render()line 77 of /theme/base/layout/general.php: call to core_renderer->navbar()line 841 of /lib/outputrenderers.php: call to include()line 771 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()line 240 of /course/view.php: call to core_renderer->header()
          Hide
          Dan Poltawski added a comment -

          I think this must be something navigation related

          Show
          Dan Poltawski added a comment - I think this must be something navigation related
          Hide
          Sam Hemelryk added a comment -

          Patch up for integration now

          Show
          Sam Hemelryk added a comment - Patch up for integration now
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Sent to integration, although, strangely... the error I was getting before the patch was radically different, something like:

          PHP Error: can not find class coursecat, in navigationlib line xxxxx

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Sent to integration, although, strangely... the error I was getting before the patch was radically different, something like: PHP Error: can not find class coursecat, in navigationlib line xxxxx Ciao
          Hide
          Marina Glancy added a comment -

          there was another problem I noticed yesterday but it was too late and I did not find the solution. I tried opening all course pages and checking the navbar and on Badges page it falls back to the navbar without categories.

          Show
          Marina Glancy added a comment - there was another problem I noticed yesterday but it was too late and I did not find the solution. I tried opening all course pages and checking the navbar and on Badges page it falls back to the navbar without categories.
          Hide
          Marina Glancy added a comment -

          Eloy, I also had this error
          https://tracker.moodle.org/browse/MDL-37762?focusedCommentId=215581&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-215581
          coursecat class was used but coursecatlib.php was not included. In this patch the class is not used at all.

          Show
          Marina Glancy added a comment - Eloy, I also had this error https://tracker.moodle.org/browse/MDL-37762?focusedCommentId=215581&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-215581 coursecat class was used but coursecatlib.php was not included. In this patch the class is not used at all.
          Hide
          Marina Glancy added a comment -

          and since I started looking at this issue.... Let me remind you about all the related settings that we have under Administration -> Appearence -> Navigation:

          • Show course categories (navshowcategories) Default: Yes Show course categories in the navigation bar and navigation blocks. This does not occur with courses the user is currently enrolled in, they will still be listed under mycourses without categories.
          • Show my course categories (navshowmycoursecategories) Default: No If enabled courses in the users my courses branch will be shown in categories.
          • Link admin categories (linkadmincategories) Default: No If enabled admin setting categories will be displayed as links in the navigation and will lead to the admin category pages.

          we only look at first in this patch

          Show
          Marina Glancy added a comment - and since I started looking at this issue.... Let me remind you about all the related settings that we have under Administration -> Appearence -> Navigation: Show course categories (navshowcategories) Default: Yes Show course categories in the navigation bar and navigation blocks. This does not occur with courses the user is currently enrolled in, they will still be listed under mycourses without categories. Show my course categories (navshowmycoursecategories) Default: No If enabled courses in the users my courses branch will be shown in categories. Link admin categories (linkadmincategories) Default: No If enabled admin setting categories will be displayed as links in the navigation and will lead to the admin category pages. we only look at first in this patch
          Hide
          Marina Glancy added a comment -

          created a new issue MDL-39142 to address my previous comments

          Show
          Marina Glancy added a comment - created a new issue MDL-39142 to address my previous comments
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Yeah, the error you comment there is the one I was getting here.

          grrr, sorry I was not aware of those (2.3, wow!) settings, grrr.

          How complex life is, apologies and thanks for getting onto it.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Yeah, the error you comment there is the one I was getting here. grrr, sorry I was not aware of those (2.3, wow!) settings, grrr. How complex life is, apologies and thanks for getting onto it. Ciao
          Hide
          Damyon Wiese added a comment -

          I double checked and this needs backporting to 24. (will cherry-pick now).

          Show
          Damyon Wiese added a comment - I double checked and this needs backporting to 24. (will cherry-pick now).
          Hide
          Damyon Wiese added a comment -

          24 backport done and pushed - please also test on 24 branch.

          Show
          Damyon Wiese added a comment - 24 backport done and pushed - please also test on 24 branch.
          Hide
          Frédéric Massart added a comment -

          Works as expected on 2.4 and master. Confirmed with Sam that when the setting is disabled we do not show the nodes "My courses" or "Courses" in the navbar.

          Passed the test MDL-37762 along with this one

          Show
          Frédéric Massart added a comment - Works as expected on 2.4 and master. Confirmed with Sam that when the setting is disabled we do not show the nodes "My courses" or "Courses" in the navbar. Passed the test MDL-37762 along with this one
          Hide
          Dan Poltawski added a comment -

          Blooming Marvelous! It's time for a knees up - your changes are upstream!

          Thanks for making Moodle better!

          Toodle pip

          Show
          Dan Poltawski added a comment - Blooming Marvelous! It's time for a knees up - your changes are upstream! Thanks for making Moodle better! Toodle pip

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: