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

Category depths not set during upgrade. Breaks contexts.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.9, 2.0
    • Component/s: Database SQL/XMLDB
    • Labels:
      None
    • Environment:
      Tested under Postgres 8.1.9 and MySQL 4.1.20, PHP 4.3.9
    • Database:
      MySQL, PostgreSQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE

      Description

      When upgrading from 1.5.x to 1.9, the category depth and path columns are added. The intended use appears to be that 1 is a top level depth. During the upgrades, the column is added with a default value of 0, and is never set to anything else.

      In version previous to 1.9 this didn't seem to matter much, as soon as you add or move a category it sets everything properly.

      In 1.9 when build_context_path is called, in the sql that builds the context paths for the categories, there are 2 sets of sql. One that builds paths for top level categories (depth=1) and one that steps through from 2 to maxdepth. Categories that have an improper depth of 0 get skipped over, and their context retains a path off NULL and a depth of 1.

      When the course paths are calculated in the next section, they append their context id to the path of their category, which in this case have a path of NULL, which you can't append to, breaking the context path for all the children courses of that category.

      I think there are really 2 things to fix this. One, update the code where depth is first added (1.6? I'd have to look), and maybe add a sanity check in 1.9 in build_context_path, because this problem completely cripped the site, and I had to write a quick script to call build_context_path even when I fixed the root problem.

      I would be glad to take this ticket (it would be my first one, awww), but I wanted to get opinions before I did anything in CVS.

      -Eric Merrill

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              skodak Petr Skoda
              Reporter:
              emerrill Eric Merrill
              Tester:
              Nobody
              Participants:
              Component watchers:
              Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                3/Mar/08