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

Delete orphaned category, course, group and user-type calendar events and subscriptions

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE
    • MDL-73309-master
    • Hide
      1. Start with an unpatched Moodle version!
      2. Create a top course category "Category 1"
      3. Create a course "Course 1" within Category 1 and enrol yourself
      4. Create a group "Group 1" within Course 1
      5. In the Course Calendar, click on "Manage subscriptions"
      6. Once each for Category 1, Course 1, Group 1, import a calendar (for example the moodle release calendar https://www.google.com/calendar/ical/moodle.com_p4c2oe7hsb77ltaro5qtihb5d4%40group.calendar.google.com/public/basic.ics)
      7. Go to Site Adminstration > Courses > Manage courses and categories
      8. Delete Category 1 and choose "Move content to another category"
      9. Delete Course 1
      10. Run UPDATE mdl_event_subscriptions SET pollinterval = 1; in the DB, so you don't have to wait.
      11. Run cron
      12. Verify that the output for \core\task\calendar_cron_task shows an error for each of the three calendar subscriptions
      13. Verify that the SQL-Query SELECT id, name, categoryid, eventtype FROM mdl_event; still return events for the deleted category.
      14. Now patch and upgrade Moodle.
      15. Run cron
      16. Verify that the output for \core\task\calendar_cron_task does not list the Calendar Subscriptions anymore.
      17. Verify that the SQL-Query SELECT id, name, categoryid, eventtype FROM mdl_event; does not return events for the deleted category.
      18. Repeat Steps 2 - 11
      19. Verify that the output for \core\task\calendar_cron_task does not list the Calendar Subscriptions.
      20. Verify that the SQL-Query SELECT id, name, categoryid, eventtype FROM mdl_event; does not return events for the deleted category.
      Show
      Start with an  unpatched Moodle version! Create a top course category "Category 1" Create a course "Course 1" within Category 1 and enrol yourself Create a group "Group 1" within Course 1 In the Course Calendar, click on "Manage subscriptions" Once each for Category 1, Course 1, Group 1, import a calendar (for example the moodle release calendar https://www.google.com/calendar/ical/moodle.com_p4c2oe7hsb77ltaro5qtihb5d4%40group.calendar.google.com/public/basic.ics ) Go to Site Adminstration > Courses > Manage courses and categories Delete Category 1 and choose "Move content to another category" Delete Course 1 Run UPDATE mdl_event_subscriptions SET pollinterval = 1; in the DB, so you don't have to wait. Run cron Verify that the output for \core\task\calendar_cron_task shows an error for each of the three calendar subscriptions Verify that the SQL-Query SELECT id, name, categoryid, eventtype FROM mdl_event; still return events for the deleted category. Now patch and upgrade Moodle. Run cron Verify that the output for \core\task\calendar_cron_task does not list the Calendar Subscriptions anymore. Verify that the SQL-Query SELECT id, name, categoryid, eventtype FROM mdl_event; does not return events for the deleted category. Repeat Steps 2 - 11 Verify that the output for \core\task\calendar_cron_task does not list the Calendar Subscriptions. Verify that the SQL-Query SELECT id, name, categoryid, eventtype FROM mdl_event; does not return events for the deleted category.

      Category events itself also remain untouched in the database, when the category is deleted and courses within are moved.

      The orphaned event subscriptions cause \core\task\calendar_cron_task to show these errors.

      Execute scheduled task: Send calendar notifications (core\task\calendar_cron_task)
      ... started 23:55:24. Current memory use 60.8MB.
      Updating calendar subscription Course Subscription in course 11
      Error updating calendar subscription: Can't find data record in database table course. (SELECT id,category FROM {course} WHERE id = ?
      [array (
        0 => '11',
      )])
      Updating calendar subscription Group Subscription in course 11
      Error updating calendar subscription: Can't find data record in database table course. (SELECT id,category FROM {course} WHERE id = ?
      [array (
        0 => '11',
      )])
      Updating calendar subscription Category Subscription in course 0
      Error updating calendar subscription: Can't find data record in database table course_categories. (SELECT id,parent FROM {course_categories} WHERE id = ?
      [array (
        0 => '4',
      )])

      Replicating steps:

      1. Create a top course category "Category 1"
      2. Create a course "Course 1" within Category 1 and enrol yourself
      3. Create a group "Group 1" within Course 1
      4. In the Course Calendar, click on "Manage subscriptions"
      5. Once each for Category 1, Course 1, Group 1, import a calendar (for example the moodle release calendar https://www.google.com/calendar/ical/moodle.com_p4c2oe7hsb77ltaro5qtihb5d4%40group.calendar.google.com/public/basic.ics)
      6. Go to Site Adminstration > Courses > Manage courses and categories
      7. Delete Category 1 and choose "Move content to another category"
      8. Delete Course 1
      9. Run UPDATE mdl_event_subscriptions SET pollinterval = 1; in the DB, so you don't have to wait.
      10. Run cron
      11. The output for \core\task\calendar_cron_task shows the error for each of the three calendar subscriptions
      12. The category events are still in the event table.

            justusdieckmann Justus Dieckmann
            justusdieckmann Justus Dieckmann
            Laurent David Laurent David
            Votes:
            29 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 minutes
                6m

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