diff --git a/backup/util/plan/backup_plan.class.php b/backup/util/plan/backup_plan.class.php index 1a90b6d410a..08166210da0 100644 --- a/backup/util/plan/backup_plan.class.php +++ b/backup/util/plan/backup_plan.class.php @@ -47,6 +47,16 @@ class backup_plan extends base_plan implements loggable { parent::__construct('backup_plan'); } + /** + * Destroy all circular references. It helps PHP 5.2 a lot! + */ + public function destroy() { + // No need to destroy anything recursively here, direct reset + $this->controller = null; + // Delegate to base plan the rest + parent::destroy(); + } + public function build() { backup_factory::build_plan($this->controller); // Dispatch to correct format $this->built = true; diff --git a/backup/util/plan/base_plan.class.php b/backup/util/plan/base_plan.class.php index 97e8e387f05..3ed176b0bbf 100644 --- a/backup/util/plan/base_plan.class.php +++ b/backup/util/plan/base_plan.class.php @@ -148,6 +148,22 @@ abstract class base_plan implements checksumable, executable { $task->execute(); } } + + /** + * Destroy all circular references. It helps PHP 5.2 a lot! + */ + public function destroy() { + // Before reseting anything, call destroy recursively + foreach ($this->tasks as $task) { + $task->destroy(); + } + foreach ($this->settings as $setting) { + $setting->destroy(); + } + // Everything has been destroyed recursively, now we can reset safely + $this->tasks = array(); + $this->settings = array(); + } } diff --git a/backup/util/plan/base_step.class.php b/backup/util/plan/base_step.class.php index 96db85f5bbd..e1bc116223a 100644 --- a/backup/util/plan/base_step.class.php +++ b/backup/util/plan/base_step.class.php @@ -57,6 +57,14 @@ abstract class base_step implements executable, loggable { $this->task = $task; } + /** + * Destroy all circular references. It helps PHP 5.2 a lot! + */ + public function destroy() { + // No need to destroy anything recursively here, direct reset + $this->task = null; + } + public function log($message, $level, $a = null, $depth = null, $display = false) { if (is_null($this->task)) { throw new base_step_exception('not_specified_base_task'); diff --git a/backup/util/plan/base_task.class.php b/backup/util/plan/base_task.class.php index 341e71d4fd1..e38fa896165 100644 --- a/backup/util/plan/base_task.class.php +++ b/backup/util/plan/base_task.class.php @@ -32,7 +32,7 @@ abstract class base_task implements checksumable, executable, loggable { protected $name; // One simple name for identification purposes protected $plan; // Plan this is part of protected $settings; // One array of base_setting elements to define this task - protected $steps; // One array of base_task elements + protected $steps; // One array of base_step elements protected $built; // Flag to know if one task has been built protected $executed; // Flag to know if one task has been executed @@ -159,6 +159,23 @@ abstract class base_task implements checksumable, executable, loggable { } } + /** + * Destroy all circular references. It helps PHP 5.2 a lot! + */ + public function destroy() { + // Before reseting anything, call destroy recursively + foreach ($this->steps as $step) { + $step->destroy(); + } + foreach ($this->settings as $setting) { + $setting->destroy(); + } + // Everything has been destroyed recursively, now we can reset safely + $this->steps = array(); + $this->setting = array(); + $this->plan = null; + } + public function is_checksum_correct($checksum) { return $this->calculate_checksum() === $checksum; }