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

Duplicating activities causes duplicate rows in groupings_groups table

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • 2.0.6, 2.1.3
    • 2.1.1, 2.1.2, 2.2
    • Backup, Course
    • None
    • MOODLE_21_STABLE, MOODLE_22_STABLE
    • MOODLE_20_STABLE, MOODLE_21_STABLE
    • MDL-29350-master-2
    • Hide

      To test the duplication process:

      • Create an empty course.
      • Create one grouping in the course, then create one group in this grouping.
      • Create an activity (say, an assignment), set it to "Visible groups", and restrict it to the grouping.
      • Click the "Duplicate" button and confirm.
      • Now verify that the following query returns an empty result:

      SELECT COUNT(id) AS idcnt, MIN(id) AS firstid, groupingid, groupid FROM mdl_groupings_groups GROUP BY groupingid, groupid HAVING idcnt>1;

      To test the database cleanup:

      • Produce the bad DB entries caused by this bug (see "replication instructions" in the description)
      • Run the upgrade
      • Verify that the following query returns an empty result:

      SELECT COUNT(id) AS idcnt, MIN(id) AS firstid, groupingid, groupid FROM mdl_groupings_groups GROUP BY groupingid, groupid HAVING idcnt>1;

      Show
      To test the duplication process: Create an empty course. Create one grouping in the course, then create one group in this grouping. Create an activity (say, an assignment), set it to "Visible groups", and restrict it to the grouping. Click the "Duplicate" button and confirm. Now verify that the following query returns an empty result: SELECT COUNT(id) AS idcnt, MIN(id) AS firstid, groupingid, groupid FROM mdl_groupings_groups GROUP BY groupingid, groupid HAVING idcnt>1; To test the database cleanup: Produce the bad DB entries caused by this bug (see "replication instructions" in the description) Run the upgrade Verify that the following query returns an empty result: SELECT COUNT(id) AS idcnt, MIN(id) AS firstid, groupingid, groupid FROM mdl_groupings_groups GROUP BY groupingid, groupid HAVING idcnt>1;

      When duplicating activities in a course (using the "Duplicate" icon), duplicate records may be inserted into the groupings_groups table.

      To reproduce:

      • Create an empty course.
      • Create one grouping in the course, then create one group in this grouping.
      • Create an activity (say, an assignment), set it to "Visible groups", and restrict it to the grouping.
      • Click the "Duplicate" button and confirm.
      • Now run the following query manually on the DB:

      SELECT COUNT(id) AS idcnt, MIN(id) AS firstid, groupingid, groupid FROM mdl_groupings_groups GROUP BY groupingid, groupid HAVING idcnt>1;

      This will now show (at least) one line with idcnt=2.

      Any further duplication will double the number of rows. On my production system, there's one groupingid-groupid pair which has 16384 table entries. Since many parts of the code assume that (groupingid, groupid) is unique, this leads to various strange effects in different places of Moodle, for example in the screens that assign groups to groupings.

      The reason for this is in the backup/restore code in restore_groups_structure_step::process_grouping_group() . This "restores" a groupings_groups entry even if it already exists.

      Patch to follow.

            dobedobedoh Andrew Lyons
            bostelm Henning Bostelmann
            Dan Poltawski Dan Poltawski
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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