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

Problems with upgrade_grade_item_fix_sortorder()

XMLWordPrintable

    • MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • MOODLE_25_STABLE, MOODLE_26_STABLE
    • Hide

      You will need to start out with versions dated Jan 13 or before (2.5.4, 2.6.1, non-current master).

      (Stolen from MDL-41062):
      Setup in old Moodle:

      1. Create COURSE1 with default settings
      2. Add an assignment 'Assign 1' with default settings
      3. Create COURSE2 with default settings
      4. Add an assignment 'Assign 2' with default settings
      5. VERIFY: Examine the database and ensure the grade items exist, and both have the same sort order in different courses. e.g:

        SELECT id, itemname, courseid, sortorder 
        FROM mdl_grade_items 
        WHERE itemname LIKE 'Assign%'
        ORDER BY sortorder, courseid;
         
         id | itemname | courseid | sortorder
        ----+----------+----------+-----------
          4 | Assign 1 |        2 |         2
          2 | Assign 2 |        3 |         2
        

      Create duplicates through import:

      1. Go to COURSE1
      2. Select import, choose COURSE2
      3. Choose ONLY to import ASSIGNCOURSE2
      4. VERIFY: Examine the database and ensure the grade items that are imported have created duplicates, there should be results fem the following query:

        SELECT courseid, sortorder
        FROM {grade_items}
        GROUP BY courseid, sortorder
        HAVING COUNT(id) > 1
        

      Upgrade to current version with this patch:

      1. VERIFY: Run the same query as above, and ensure there now are no results.
      2. Go to the Gradebook of COURSE1
      3. Go to Grades > Categories and items > Simple view and ensure that the grade items for the two assignments appear
      4. VERIFY: that you can resort the grade items and they behave in the way the interface demonstrates
      Show
      You will need to start out with versions dated Jan 13 or before (2.5.4, 2.6.1, non-current master). (Stolen from MDL-41062 ): Setup in old Moodle: Create COURSE1 with default settings Add an assignment 'Assign 1' with default settings Create COURSE2 with default settings Add an assignment 'Assign 2' with default settings VERIFY: Examine the database and ensure the grade items exist, and both have the same sort order in different courses. e.g: SELECT id, itemname, courseid, sortorder FROM mdl_grade_items WHERE itemname LIKE 'Assign%' ORDER BY sortorder, courseid;   id | itemname | courseid | sortorder ----+----------+----------+----------- 4 | Assign 1 | 2 | 2 2 | Assign 2 | 3 | 2 Create duplicates through import: Go to COURSE1 Select import, choose COURSE2 Choose ONLY to import ASSIGNCOURSE2 VERIFY: Examine the database and ensure the grade items that are imported have created duplicates, there should be results fem the following query: SELECT courseid, sortorder FROM {grade_items} GROUP BY courseid, sortorder HAVING COUNT(id) > 1 Upgrade to current version with this patch: VERIFY: Run the same query as above, and ensure there now are no results. Go to the Gradebook of COURSE1 Go to Grades > Categories and items > Simple view and ensure that the grade items for the two assignments appear VERIFY: that you can resort the grade items and they behave in the way the interface demonstrates

      This is a regression of MDL-41062 which landed recently.

      It seems that the main query of upgrade_grade_item_fix_sortorder() returns too many records, leading to the iteration later in code to perform way many updates (slow and advancing too much).

      More details, for your consideration in this comment.

      Ciao

            emerrill Eric Merrill
            stronk7 Eloy Lafuente (stronk7)
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Sam Hemelryk Sam Hemelryk
            Mark Nelson Mark Nelson
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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