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

calendar_upcoming and calendar_month blocks sometimes break

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Calendar
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      In some courses, inserting the calendar_upcoming or calendar_month block causes a few errors to be displayed:
      Notice: Trying to get property of non-object in C:\xampp\htdocs\moodle2-hq\lib\moodlelib.php on line 5842

      That one's repeated three times, followed by:
      Fatal error: Exception thrown without a stack frame in Unknown on line 0

      I've narrowed it down to the call to calendar_session_vars($this->page->course) on line 19 of block_calendar_upcoming.php and line 23 of block_calendar_month.php. For some courses, the course object that gets passed in to this function contains a coursenode object, while in other seemingly identical courses it does not (it presumably gets added at some stage after the block is generated in these cases). If the coursenode object is present in the course object that gets passed in to calendar_session_vars(), the above errors occur - removing the coursenode object prevents them from happening.

      I've attached a patch which, if the coursenode is present, clones the course object, removes the coursenode from the clone, and places the clone into $SESSION->cal_courses_shown rather than the original. If somebody who understands this better than I do has a suggestion on a better fix, please contribute - this may not be the best way to fix it, but it does the trick.

        Attachments

          Activity

            People

            • Assignee:
              samhemelryk Sam Hemelryk
              Reporter:
              paul.n Paul Nicholls
              Tester:
              Nobody
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                24/Nov/10