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

Loading calendar events for user in huge number of courses errors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Deferred
    • Icon: Minor Minor
    • None
    • 3.3.3, 3.4
    • Calendar

      When trying to view the calendar for a user that has access to huge numbers of courses (tens of thousands) the query to retrieve the events fails because it attempts to set each course id as a query param which exceeds the maximum param count on the DB engine. This typically occurs on a large site when viewing the calendar as admin with the calendar_adminseesall config value set to true.

      This was discovered by Eric in MDL-60402. See this comment for more details.

      Here's the exception:

      Debug info: number of parameters must be between 0 and 65535
      SELECT e.*
      FROM mdl_event e
      INNER JOIN (SELECT ev.modulename,
      ev.instance,
      ev.eventtype,
      MIN(ev.priority) as priority
      FROM mdl_event ev
      WHERE (ev.userid = $1 AND ev.courseid = 0 AND ev.groupid = 0 AND ev.categoryid = 0) OR (ev.groupid != 0 AND ev.eventtype = 'group') OR (ev.groupid = 0 AND ev.courseid IN ($2,$3,$4 ... $47128,$47129,$47130) AND ev.categoryid = 0) OR (ev.groupid = 0 AND ev.courseid = 0 AND ev.categoryid IN ($47131,$47132,$47133 ... $47204,$47205,$47206))
      GROUP BY ev.modulename, ev.instance, ev.eventtype) fe
      ON e.modulename = fe.modulename
      AND e.instance = fe.instance
      AND e.eventtype = fe.eventtype
      AND (e.priority = fe.priority OR (e.priority IS NULL AND fe.priority IS NULL))
      LEFT JOIN mdl_modules m
      ON e.modulename = m.name
      WHERE (m.visible = 1 OR m.visible IS NULL) AND (timestart >= $47207 OR timestart + timeduration > $47208) AND timestart <= $47209 AND ((e.userid = $47210 AND e.courseid = 0 AND e.groupid = 0 AND e.categoryid = 0) OR e.groupid != 0 OR (e.groupid = 0 AND e.courseid IN ($47211,$47212,$47213 ... $94337,$94338,$94339)) OR (e.groupid = 0 AND e.courseid = 0 AND e.categoryid IN ($94340,$94341 ... $94414,$94415))) AND (e.visible = 1)
      ORDER BY COALESCE(e.timesort, e.timestart) ASC, e.id ASC LIMIT 200
      [array (
      0 => '202822',
      1 => 4,
      2 => 7,
      3 => 11,
        ....
      94412 => '193',
      94413 => '194',
      94414 => '294',
      )]
      Error code: dmlreadexception
      Stack trace:
      * line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
      * line 242 of /lib/dml/pgsql_native_moodle_database.php: call to moodle_database->query_end()
      * line 776 of /lib/dml/pgsql_native_moodle_database.php: call to pgsql_native_moodle_database->query_end()
      * line 275 of /calendar/classes/local/event/strategies/raw_event_retrieval_strategy.php: call to pgsql_native_moodle_database->get_records_sql()
      * line 55 of /calendar/classes/local/event/strategies/raw_event_retrieval_strategy.php: call to core_calendar\local\event\strategies\raw_event_retrieval_strategy->get_raw_events_legacy_implementation()
      * line 171 of /calendar/classes/local/event/data_access/event_vault.php: call to core_calendar\local\event\strategies\raw_event_retrieval_strategy->get_raw_events()
      * line 94 of /calendar/classes/local/api.php: call to core_calendar\local\event\data_access\event_vault->get_events()
      * line 3453 of /calendar/lib.php: call to core_calendar\local\api::get_events()
      * line 54 of /blocks/calendar_month/block_calendar_month.php: call to calendar_get_view()
      * line 288 of /blocks/moodleblock.class.php: call to block_calendar_month->get_content()
      * line 230 of /blocks/moodleblock.class.php: call to block_base->formatted_contents()
      * line 1205 of /lib/blocklib.php: call to block_base->get_content_for_output()
      * line 1257 of /lib/blocklib.php: call to block_manager->create_block_contents()
      * line 579 of /lib/outputrenderers.php: call to block_manager->ensure_content_created()
      * line 39 of /theme/bootstrapbase/renderers/core_renderer.php: call to core_renderer->standard_head_html()
      * line 44 of /theme/ou_bs_base/layout/columns3.php: call to theme_bootstrapbase_core_renderer->standard_head_html()
      * line 1261 of /lib/outputrenderers.php: call to include()
      * line 1191 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
      * line 164 of /my/index.php: call to core_renderer->header()
      

            dobedobedoh Andrew Lyons
            ryanwyllie Ryan Wyllie
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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