Moodle

Avoid infinite loops when moode gets course_category structure

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Critical 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]);
}

Issue Links

Activity

Hide
Petr Škoda (skodak) added a comment -

rewritten code does not have this problem anymore
thanks for the report

Show
Petr Škoda (skodak) added a comment - rewritten code does not have this problem anymore thanks for the report

Dates

  • Created:
    Updated:
    Resolved: