Merge branch 'MDL-28687' of git://github.com/timhunt/moodle
authorAparup Banerjee <aparup@moodle.com>
Tue, 23 Aug 2011 18:24:08 +0000 (02:24 +0800)
committerAparup Banerjee <aparup@moodle.com>
Tue, 23 Aug 2011 18:24:08 +0000 (02:24 +0800)
lib/questionlib.php

index fe52dfe..446fa95 100644 (file)
@@ -1343,6 +1343,11 @@ function question_has_capability_on($question, $cap, $cachecat = -1) {
         }
         $question = $questions[$question];
     }
+    if (empty($question->category)) {
+        // This can happen when we have created a fake 'missingtype' question to
+        // take the place of a deleted question.
+        return false;
+    }
     if (!isset($categories[$question->category])) {
         if (!$categories[$question->category] = $DB->get_record('question_categories',
                 array('id'=>$question->category))) {