Permalink
Browse files

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

  • Loading branch information...
tmuras committed Sep 20, 2012
1 parent 9273bd1 commit 24d9d1811f8b91c43a5c604c1eb07eea7c499804
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 24d9d18

Please sign in to comment.