Permalink
Browse files

MDL-35547 Detect question category pointing to itself as a parent.

  • Loading branch information...
1 parent 5d6285c commit e3810d112a2eb24db6a94bb1a44e10b3e919a4e2 @tmuras tmuras committed Sep 20, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/questionlib.php
View
@@ -1184,6 +1184,10 @@ function question_categorylist($categoryid) {
$categorylist = array($categoryid);
foreach ($subcategories as $subcategory) {
+ if($subcategory->id == $categoryid)
+ //prevent infinite loop
+ throw new coding_exception("Question category $categoryid points to itself as a parent.");
+ }
$categorylist = array_merge($categorylist, question_categorylist($subcategory->id));
}

0 comments on commit e3810d1

Please sign in to comment.