Moodle
  1. Moodle
  2. MDL-6130

Upcoming Events block broken on homepage

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6.1
    • Component/s: Calendar
    • Labels:
      None
    • Environment:
      All
    • Affected Branches:
      MOODLE_16_STABLE
    • Fixed Branches:
      MOODLE_16_STABLE
    • Rank:
      28465

      Description

      the upcoming events block doesn't work properly on the homepage anymore - it doesn't display any upcoming events, and if you try to add an event via the upcoming events block when attached to the site homepage you get this error:

      Incorrect course ID

      I'm guessing it's a result of the changes made with MDL-5909

      Dan

        Activity

        Hide
        Martin Dougiamas added a comment -

        From Dan Marsden (dan at digitalclay.co.nz) Monday, 17 July 2006, 09:54 AM:

        line487ish of calendar/event.php:

        $courseid = optional_param('courseid', $SESSION->cal_course_referer, PARAM_INT);

        $courseid = 0 when this is called on the site homepage - is this right?

        • I've added the following code as a workaround for the meantime....

        $courseid = optional_param('courseid', $SESSION->cal_course_referer, PARAM_INT);

        if ($courseid == 0)

        { //bug fix. - events don't work! $courseid=1; }
        • for anyone else reading, this isn't a proper fix! - just a workaround...

        Dan

        From Petr Skoda (skodak at centrum.cz) Monday, 17 July 2006, 03:34 PM:

        I have committed your workaround into cvs. The use of SESSION in calendar is IMHO broken. Keeping open for now...

        Thanks for the workaround!

        From Dan Marsden (dan at digitalclay.co.nz) Friday, 21 July 2006, 05:18 AM:

        the old workaround doesn't fix it completely - we also need to add the following code to calendar/lib.php (or somewhere else to fix the $courses array created.)

        the problem is that the array is created with a blank entry at the top by function calendar_set_filters()

        this var: $SESSION->cal_courses_shown

        when set has a bung entry at the top, so when finally the WHERECLAUSE is created for getting back all the events that need to be shown, the where clause looks a bit like this

        groupid = 0 AND courseid IN (,1,4)

        (the extra , in the above statement causes problems.)

        I've added the following lines as a workaround:

        if (empty($courses[0]))

        { //dan BUG! unset($courses[0]); }

        around line 1096 in lib.php under the following lines:

        else if($SESSION->cal_show_global)

        { $courses = array(SITEID); }

        else

        { $courses = false; }

        the workaround could possibly be altered to run through the array and clean it by removing all empty items instead of just the first one.....or is there already a moodle function that will clean an array?

        Dan

        From Dan Marsden (dan at digitalclay.co.nz) Friday, 21 July 2006, 06:01 AM:

        unless we have a moodle clean array function - this should be used to clean the whole array instead of just the first value.

        foreach ($courses as $index => $value)

        { if(is_array($courses[$index])) $courses[$index] = cleanArray($courses[$index]); if (empty($value)) unset($courses[$index]); }

        From Dan Marsden (dan at digitalclay.co.nz) Monday, 24 July 2006, 08:17 AM:

        added clean array workaround to HEAD and 1.6_stable

        Show
        Martin Dougiamas added a comment - From Dan Marsden (dan at digitalclay.co.nz) Monday, 17 July 2006, 09:54 AM: line487ish of calendar/event.php: $courseid = optional_param('courseid', $SESSION->cal_course_referer, PARAM_INT); $courseid = 0 when this is called on the site homepage - is this right? I've added the following code as a workaround for the meantime.... $courseid = optional_param('courseid', $SESSION->cal_course_referer, PARAM_INT); if ($courseid == 0) { //bug fix. - events don't work! $courseid=1; } for anyone else reading, this isn't a proper fix! - just a workaround... Dan From Petr Skoda (skodak at centrum.cz) Monday, 17 July 2006, 03:34 PM: I have committed your workaround into cvs. The use of SESSION in calendar is IMHO broken. Keeping open for now... Thanks for the workaround! From Dan Marsden (dan at digitalclay.co.nz) Friday, 21 July 2006, 05:18 AM: the old workaround doesn't fix it completely - we also need to add the following code to calendar/lib.php (or somewhere else to fix the $courses array created.) the problem is that the array is created with a blank entry at the top by function calendar_set_filters() this var: $SESSION->cal_courses_shown when set has a bung entry at the top, so when finally the WHERECLAUSE is created for getting back all the events that need to be shown, the where clause looks a bit like this groupid = 0 AND courseid IN (,1,4) (the extra , in the above statement causes problems.) I've added the following lines as a workaround: if (empty($courses [0] )) { //dan BUG! unset($courses[0]); } around line 1096 in lib.php under the following lines: else if($SESSION->cal_show_global) { $courses = array(SITEID); } else { $courses = false; } the workaround could possibly be altered to run through the array and clean it by removing all empty items instead of just the first one.....or is there already a moodle function that will clean an array? Dan From Dan Marsden (dan at digitalclay.co.nz) Friday, 21 July 2006, 06:01 AM: unless we have a moodle clean array function - this should be used to clean the whole array instead of just the first value. foreach ($courses as $index => $value) { if(is_array($courses[$index])) $courses[$index] = cleanArray($courses[$index]); if (empty($value)) unset($courses[$index]); } From Dan Marsden (dan at digitalclay.co.nz) Monday, 24 July 2006, 08:17 AM: added clean array workaround to HEAD and 1.6_stable
        Hide
        Dan Marsden added a comment -

        by the looks of things - I fixed this in 1.6.1 - and should have closed the bug!

        Show
        Dan Marsden added a comment - by the looks of things - I fixed this in 1.6.1 - and should have closed the bug!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: