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

Attempt to read property "instanceid" on bool

XMLWordPrintable

      MDL-82427 caused a regression in some Moodle sites using filters:

       

      dobedobedoh found and fixed it:

      -       if (!$coursectx) {
      -            // We could be in a course category so no entries for courseid == 0 will be found.
      -            $courseid = 0;
      -        } else {
      -            $courseid = $coursectx->instanceid;
      -        }
      +        // We could be in a course category so no entries for courseid == 0 will be found.
      +        $courseid = $coursectx?->instanceid ?: 0;
       
      

       

      So the fix is

              // Try to get current course.
              // We could be in a course category so no entries for courseid == 0 will be found.
              $courseid = 0;
              if ($coursectx = $this->context->get_course_context(false)) {
                  $courseid = $coursectx->instanceid;
              }

       

      I've been able to confirm that this patch fixes the error in my local site

            dobedobedoh Andrew Lyons
            sarjona Sara Arjona (@sarjona)
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Paul Holden Paul Holden
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 13 minutes
                13m

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