Permalink
Browse files

Merge branch 'MDL-34251_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
2 parents 5d68428 + b0e0762 commit 59cc0091527e5589c4a2dbdb244776f21116f756 @danpoltawski danpoltawski committed Jul 23, 2012
Showing with 17 additions and 0 deletions.
  1. +9 −0 question/engine/questionattempt.php
  2. +8 −0 question/engine/questionusage.php
View
9 question/engine/questionattempt.php
@@ -1213,6 +1213,15 @@ public static function load_from_records($records, $questionattemptid,
$qa->behaviour = question_engine::make_behaviour(
$record->behaviour, $qa, $preferredbehaviour);
+ // If attemptstepid is null (which should not happen, but has happened
+ // due to corrupt data, see MDL-34251) then the current pointer in $records
+ // will not be advanced in the while loop below, and we get stuck in an
+ // infinite loop, since this method is supposed to always consume at
+ // least one record. Therefore, in this case, advance the record here.
+ if (is_null($record->attemptstepid)) {
+ $records->next();
+ }
+
$i = 0;
while ($record && $record->questionattemptid == $questionattemptid && !is_null($record->attemptstepid)) {
$qa->steps[$i] = question_attempt_step::load_from_records($records, $record->attemptstepid);
View
8 question/engine/questionusage.php
@@ -706,6 +706,14 @@ public static function load_from_records($records, $qubaid) {
$quba->observer = new question_engine_unit_of_work($quba);
+ // If slot is null then the current pointer in $records will not be
+ // advanced in the while loop below, and we get stuck in an infinite loop,
+ // since this method is supposed to always consume at least one record.
+ // Therefore, in this case, advance the record here.
+ if (is_null($record->slot)) {
+ $records->next();
+ }
+
while ($record && $record->qubaid == $qubaid && !is_null($record->slot)) {
$quba->questionattempts[$record->slot] =
question_attempt::load_from_records($records,

0 comments on commit 59cc009

Please sign in to comment.