Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit e3810d112a2eb24db6a94bb1a44e10b3e919a4e2 1 parent 5d6285c
@tmuras tmuras authored
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));
}
Please sign in to comment.
Something went wrong with that request. Please try again.