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

Duplicating activities causes duplicate rows in groupings_groups table

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1.1, 2.1.2, 2.2
    • Fix Version/s: 2.0.6, 2.1.3
    • Component/s: Backup, Course
    • Labels:
      None
    • Testing Instructions:
      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;
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-29350-master-2

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dobedobedoh Andrew Nicols
              Reporter:
              bostelm Henning Bostelmann
              Peer reviewer:
              Dan Poltawski
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                28/Nov/11