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

Adding a new health check to detect incorrect category path order and/or missing parent categories

XMLWordPrintable

    • MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_29_STABLE
    • MOODLE_29_STABLE
    • MDL-34684_master
    • Hide
      • Run admin/tool/health/tests/healthlib_test.php
      • All SHOULD pass
      • Create a set of course categories
      • Go to the database and:
        • Change the category parent to its own id
        • Select 3 categories and make them point the parent to each other id (for example category 6 parent is 7, category 7 parent is 8 and category 8 parent is 6)
        • Change path values of these categories too
      • Go to admin/tool/health/index.php
        • All the nasty things you just did SHOULD be reported there
        • Click on 'view solution' inside Course categories tree structure
        • Execute the proposed database query in your database
        • Run admin/health/index.php again
        • You SHOULD NOT see any problem related with course categories
      Show
      Run admin/tool/health/tests/healthlib_test.php All SHOULD pass Create a set of course categories Go to the database and: Change the category parent to its own id Select 3 categories and make them point the parent to each other id (for example category 6 parent is 7, category 7 parent is 8 and category 8 parent is 6) Change path values of these categories too Go to admin/tool/health/index.php All the nasty things you just did SHOULD be reported there Click on 'view solution' inside Course categories tree structure Execute the proposed database query in your database Run admin/health/index.php again You SHOULD NOT see any problem related with course categories
    • 20
    • BACKEND Sprint 18

      Some sites have corrupted hierarchies between course categories, in course_categories->parent field or in course_categories->path. The cause of this issue is not present in the current maintained versions and not all sites are affected by it, so instead of adding an upgrade process we add an extra health check process to explain to the users how to fix the problem, proposing them a sql query to run into the database.

      Edited summary and description
      --------------------------------------------------------------

      Original description

      upgraded from moodle.2.1.1 to moodle.2.2.4 and then finally to Moodle 2.3.1+ (Build: 20120726)
      PHP PHP 5.3.2-1ubuntu4.17
      MySQL 5.1.63-0ubuntu0.10.04.1-log
      Ubuntu 10.04.4 LTS

      When I click on a course category it gives me this error (with full debug on):

      Notice: Undefined index: 5 in /var/www/moodle/lib/navigationlib.php on line 1796 Notice: Trying to get property of non-object in /var/www/moodle/lib/navigationlib.php on line 1797 Notice: Trying to get property of non-object in /var/www/moodle/lib/navigationlib.php on line 1801
       
      Coding error detected, it must be fixed by a programmer: Category path order is incorrect and/or there are missing categories
       
      Debug info: 
      Error code: codingerror
      Stack trace:
      line 1809 of /lib/navigationlib.php: coding_exception thrown
      line 1195 of /lib/navigationlib.php: call to global_navigation->load_all_categories()
      line 3039 of /lib/navigationlib.php: call to global_navigation->initialise()
      line 781 of /lib/pagelib.php: call to navbar->has_items()
      line 3 of /theme/aardvark_postit/layout/default.php: call to moodle_page->has_navbar()
      line 765 of /lib/outputrenderers.php: call to include()
      line 712 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
      line ? of unknownfile: call to core_renderer->header()
      line 1445 of /lib/setuplib.php: call to call_user_func_array()
      line ? of unknownfile: call to bootstrap_renderer->__call()
      line 199 of /course/category.php: call to bootstrap_renderer->header()
      

      As an admin I can go to the course categories with no errors. But when I'm not logged in, I can't. Or other roles.

      This fix script doesn't change anything:

      <?php
       
      require_once('config.php');
       
      echo 'Starting fix_course_sortorder()...';
      fix_course_sortorder();
      echo 'done';
      

      Summary and description edited, original summary was:
      Category path order is incorrect and/or there are missing categories

        1. database1.png
          database1.png
          431 kB
        2. database2.png
          database2.png
          426 kB
        3. database3.png
          database3.png
          428 kB
        4. diff.txt
          6 kB
        5. navigationlib.php
          203 kB

            dmonllao David Monllaó
            jchapman-atomic Joe C.
            Frédéric Massart Frédéric Massart
            Sam Hemelryk Sam Hemelryk
            Ankit Agarwal Ankit Agarwal
            Votes:
            6 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved:

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