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

This commit is contained in:
M Kassaei
2012-04-02 11:03:53 +08:00
committed by Dan Poltawski
parent 6931d54085
commit 2d8d02481a
+6 -2
View File
@@ -372,6 +372,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();
@@ -404,6 +405,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();
}
/**
@@ -443,7 +449,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);
}
@@ -492,7 +497,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]);
}