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

mdl_context paths get corrupted when moving course categories

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Not a bug
    • Affects Version/s: 1.9.10
    • Fix Version/s: None
    • Component/s: Course
    • Labels:
      None
    • Environment:
      LAMP, but really n/a
    • Database:
      MySQL
    • URL:
      n/a
    • Difficulty:
      Difficult
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      This is not a Moodle core issue. This bug can be closed. Thank you.

        Gliffy Diagrams

          Activity

          jsilve1 Jeffrey Silverman created issue -
          dougiamas Martin Dougiamas made changes -
          Field Original Value New Value
          Workflow MDL Workflow [ 67276 ] MDL Full Workflow [ 75750 ]
          jsilve1 Jeffrey Silverman made changes -
          Description *Description*
          mdl_context path column is not properly cleaned up when course categories are moved around. This ends up affecting all courses in the category, and all instances of "stuff" that are managed in mdl_context table. (e.g. quizzes)

          Problem is exhibited as follows:

          * User sees error "This is an unknown context () in print_context_name!" when clicking on "Edit" tab in a quiz.
          * Searching the mdl_context table produces many path entries that do not have corresponding rows for parts of the path. For example, using an instanceid I got from first visiting a quiz URL:
          {noformat}mysql> select * from mdl_context where instanceid in (40767);
          +-------+--------------+------------+----------------------------+-------+
          | id | contextlevel | instanceid | path | depth |
          +-------+--------------+------------+----------------------------+-------+
          | 44611 | 70 | 40767 | /1/25599/25282/25291/44611 | 5 |
          +-------+--------------+------------+----------------------------+-------+
          1 row in set (0.10 sec)
          {noformat}

          Then, searching for the rows in that path:
          {noformat}mysql> select * from mdl_context where id in (1,25282,25291,25599,44611);
          +-------+--------------+------------+----------------+-------+
          | id | contextlevel | instanceid | path | depth |
          +-------+--------------+------------+----------------+-------+
          | 1 | 10 | 0 | /1 | 1 |
          | 25599 | 50 | 462 | /1/25599 | 4 |
          | 44611 | 70 | 40767 | /1/25599/44611 | 5 |
          +-------+--------------+------------+----------------+-------+
          3 rows in set (0.13 sec)
          {noformat}

          You can see that rows 25282 and 25291 are missing!



          The fix, to get the course operational again, is to remove that path section from the mdl_context table:
          {noformat}update mdl_context set path = replace(path,'/25282/25291/','/') WHERE path like '%/25282/25291/%' ;
          {noformat}

          But obviously, this is not a *bug fix*, this is just fixing the acute problem to make the site usable.

          I will post the following once I have more data:

          * Reproducible set of steps
          * Site you can hammer on to see the steps in action
          * Some ideas on where the bug actually occurs in the codebase.

          Thank you
          This is not a Moodle core issue. This bug can be closed. Thank you.
          URL pending n/a
          stronk7 Eloy Lafuente (stronk7) made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          stronk7 Eloy Lafuente (stronk7) made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          mr-russ Russell Smith made changes -
          Status Reopened [ 4 ] Closed [ 6 ]
          Assignee moodle.com [ moodle.com ] Russell Smith [ mr-russ ]
          Resolution Not a bug [ 7 ]

            People

            • Votes:
              17 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: