Permalink
Browse files

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

  • Loading branch information...
1 parent a81e8c4 commit 4bc0b067b61c01c886c4ff458c8a28537317b33a @mkassaei mkassaei committed Mar 27, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 mod/quiz/report/overview/report.php
@@ -374,6 +374,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();
@@ -406,6 +407,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();
}
/**
@@ -445,7 +451,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);
}
@@ -494,7 +499,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 4bc0b06

Please sign in to comment.