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

repeat_event_collection does not sort and skips first result

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 3.3.2, 3.4
    • Fix Version/s: 3.3.3
    • Component/s: Calendar
    • Labels:

      Description

      So this has just arrived due to a change in the existing indexes I suspect.

      The repeat_event_collection does not consider the original event to be part of the collection.
      Additionally, when fetching the events, it skips the first event, and does not sort them.

      Considering the following situation:

      Original: id 13, repeatid 13
      Repeat 1: id 8, repeatid 13
      Repeat 2: id 10, repeatid 13
      Repeat 3: id 12, repeatid 13
      

      If sorted as above, then the current query:

      SELECT * FROM event WHERE repeatid = 13 LIMIT 100 START 1
      

      Will return:

      • Repeat 1
      • Repeat 2
      • Repeat 3

      We apply a default start value of 1, which removes the first record

      Now assume that we sort by id, we'll instead get:

      • Repeat 2
      • Repeat 3
      • Original

      We could sort by timestort, but that's probably not ideal.

      I think we have two options:

      1. actively exclude WHERE id = ? and sort by id ASC
      2. actively exclude WHERE id = ? and sort by COALESCE(timesort, timestart) ASC

      Since the actual order does not matter, I vote we go for the cheapest order (id).

      As a third consideration, we need to decide whether a repeat event collection should actually contain the original event too. I think we'll discuss that in a separate issue due to the change of behaviour.
      This currently causes unit test failures on Oracle:

      1) core_calendar_repeat_event_collection_testcase::test_values_collection
      Undefined index: event name
       
      /var/www/html/moodle/calendar/tests/repeat_event_collection_test.php:118
      /var/www/html/moodle/lib/phpunit/classes/advanced_testcase.php:80
      
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  13/Nov/17