Permalink
Browse files

MDL-32214 quiz regrading: with many attempts, PHP runs out of memory

  • Loading branch information...
1 parent 6931d54 commit 2d8d02481a53f42abe4fc405fb9c47ac19507ac9 @mkassaei mkassaei committed with danpoltawski Mar 27, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 mod/quiz/report/overview/report.php
@@ -372,6 +372,7 @@ public function display($quiz, $cm, $course) {
*/
protected function regrade_attempt($attempt, $dryrun = false, $slots = null) {
global $DB;
+ set_time_limit(30);
$transaction = $DB->start_delegated_transaction();
@@ -404,6 +405,11 @@ protected function regrade_attempt($attempt, $dryrun = false, $slots = null) {
}
$transaction->allow_commit();
+
+ // Really, PHP should not need this hint, but without this, we just run out of memory.
+ $quba = null;
+ $transaction = null;
+ gc_collect_cycles();
}
/**
@@ -443,7 +449,6 @@ protected function regrade_attempts($quiz, $dryrun = false,
$this->clear_regrade_table($quiz, $groupstudents);
foreach ($attempts as $attempt) {
- set_time_limit(30);
$this->regrade_attempt($attempt, $dryrun);
}
@@ -492,7 +497,6 @@ protected function regrade_attempts_needing_it($quiz, $groupstudents) {
$this->clear_regrade_table($quiz, $groupstudents);
foreach ($attempts as $attempt) {
- set_time_limit(30);
$this->regrade_attempt($attempt, false, $attemptquestions[$attempt->uniqueid]);
}

0 comments on commit 2d8d024

Please sign in to comment.