MDL-24962 backup - clean plan/settings circular refs on restore

This commit is contained in:
Eloy Lafuente
2010-11-15 16:08:02 +00:00
parent 32df07b4c3
commit 8231bb159b
2 changed files with 30 additions and 1 deletions
+20 -1
View File
@@ -135,6 +135,23 @@ class restore_controller extends backup implements loggable {
}
}
/**
* Clean structures used by the restore_controller
*
* This method clean various structures used by the restore_controller,
* destroying them in an ordered way, so their memory will be gc properly
* by PHP (mainly circular references).
*
* Note that, while it's not mandatory to execute this method, it's highly
* recommended to do so, specially in scripts performing multiple operations
* (like the automated backups) or the system will run out of memory after
* a few dozens of backups)
*/
public function destroy() {
// Only need to destroy circulars under the plan. Delegate to it.
$this->plan->destroy();
}
public function finish_ui() {
if ($this->status != backup::STATUS_SETTING_UI) {
throw new restore_controller_exception('cannot_finish_ui_if_not_setting_ui');
@@ -157,7 +174,9 @@ class restore_controller extends backup implements loggable {
// containing all the steps will be sent to DB. 100% (monster) useless.
if ($status == backup::STATUS_AWAITING || $status == backup::STATUS_NEED_PRECHECK) {
$this->save_controller();
$this->logger = self::load_controller($this->restoreid)->logger; // wakeup loggers
$tbc = self::load_controller($this->restoreid);
$this->logger = $tbc->logger; // wakeup loggers
$tbc->destroy(); // Clean temp controller structures
}
}