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

Avoid infinite loops when moode gets course_category structure

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.7.1
    • Fix Version/s: 1.9
    • Component/s: Course
    • Labels:
      None
    • Affected Branches:
      MOODLE_17_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      If the course_category database in moodle have a course_category which is your own parent (course_category->parent=course_category_id)
      moodle do an infinite loops trying to build course_category tree, and consumig all memory in the server.

      i suggest to avoid this add a line in lib/datalib.php

      on the function get_categories

      in the foreach (line 802):

      foreach ($categories as $key => $category) {
      if (!$category->visible) {
      if (!$creator)

      { unset($categories[$key]); }
      }
      }

      chage to:

      foreach ($categories as $key => $category) {
      if (!$category->visible) {
      if (!$creator) { unset($categories[$key]); }

      }
      //Changed code
      if ($category->id==$category->parent) unset($categories[$key]);
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              martinlanghoff Martín Langhoff
              Reporter:
              bozohrj Carlos Alexandre S. da Fonseca
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

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