From 011187104f04ef6be208b48dbe3f8e0faeec7e7b Mon Sep 17 00:00:00 2001 From: M Kassaei Date: Tue, 27 Mar 2012 14:23:05 +0100 Subject: [PATCH] MDL-32214 quiz regrading: with many attempts, PHP runs out of memory --- mod/quiz/report/overview/report.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index c7e268149d4..0b82f201bb0 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -374,6 +374,7 @@ class quiz_overview_report extends quiz_attempt_report { */ protected function regrade_attempt($attempt, $dryrun = false, $slots = null) { global $DB; + set_time_limit(30); $transaction = $DB->start_delegated_transaction(); @@ -406,6 +407,11 @@ class quiz_overview_report extends quiz_attempt_report { } $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 @@ class quiz_overview_report extends quiz_attempt_report { $this->clear_regrade_table($quiz, $groupstudents); foreach ($attempts as $attempt) { - set_time_limit(30); $this->regrade_attempt($attempt, $dryrun); } @@ -494,7 +499,6 @@ class quiz_overview_report extends quiz_attempt_report { $this->clear_regrade_table($quiz, $groupstudents); foreach ($attempts as $attempt) { - set_time_limit(30); $this->regrade_attempt($attempt, false, $attemptquestions[$attempt->uniqueid]); } -- 2.43.0