From 2a73f863ffc3b2da65355f1132485ed18ff3ae07 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 16 Aug 2011 11:36:54 +0100 Subject: [PATCH] MDL-28687 questions avoid fatal errors when reviewing attempts at deleted questions. --- lib/questionlib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/questionlib.php b/lib/questionlib.php index fe52dfefff7..446fa95783b 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -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))) { -- 2.17.1