davosmith/moodle — comment on commit 06803e85d5c059f38e21046d8aba49a86b84d805
File: lib/datalib.php line 1432
By davosmith:

Note there is a subtle bug in this section, caused by the iterator in the static '$allcategories' array being clobbered by the inner loops.

To fix it, change the above code to:

$catids = array_keys($allcategories);
foreach ($catids as $catid) {
if ($allcategories[$catid] == $categoryid) {
$found = true;
$n = fix_course_sortorder($catid, $n, $safe, $depth, $path);