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

This commit is contained in:
M Kassaei
2012-04-02 11:04:05 +08:00
committed by Dan Poltawski
parent 530eecc0f9
commit 011187104f
+6 -2
View File
@@ -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]);
}