Skip to content
Browse files

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

  • Loading branch information...
1 parent c5575c6 commit 54e95b2d334851183f342da254275078d9ecb43a @tmuras tmuras committed
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/questionlib.php
View
4 lib/questionlib.php
@@ -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 54e95b2

Please sign in to comment.
Something went wrong with that request. Please try again.