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

Calendar - Adding Repeating events can hang cron infinite recursion

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.11.3
    • None
    • Calendar
    • None
    • MOODLE_311_STABLE

    Description

      In

      core_calendar\rrule_manager::create_recurring_events()

      there is the following code:

       

              foreach ($eventtimes as $time) {
                  // Skip if time is the same time with the parent event's timestamp.
                  if ($time == $event->timestart) {
                      continue;
                  }
                  // Decrement count, if set.
                  if ($count !== false) {
                      $count--;
                      if ($count == 0) {
                          break;
                      }
                  }
      

      then further down in the same function, there is a recursive call based on $count > 0

       

       

              if ($count !== false && $count > 0) {
      // SNIPPED
                  $this->create_recurring_events($event, $additionaleventtimes);
              }
      
      

      When cron attempts to import the following ics:

       

      http://ical.mac.com/ical/UK32Holidays.ics

      the recursion never terminates.

      I have fixed this in my version of the code by moving the decrement up so that it is unconditional, before the possible continue:

              foreach ($eventtimes as $time) {
       
                  // Decrement count, if set.
                  if ($count !== false) {
                      $count--;
                      if ($count == 0) {
                          break;
                      }
                  }
       
                  // Skip if time is the same time with the parent event's timestamp.
                  if ($time == $event->timestart) {
                      continue;
                  }
      
      

      I am not 100% sure whether this is the correct fix for production, but at least it allows the cron job to complete!

      Attachments

        Activity

          People

            Unassigned Unassigned
            camart Camart
            Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: