mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-24962 backup - now destroying circular refs manually to help PHP 5.2
This commit is contained in:
parent
1cf2faab39
commit
d0ad98607d
3 changed files with 34 additions and 0 deletions
|
@ -96,6 +96,9 @@ abstract class backup_structure_step extends backup_step {
|
|||
|
||||
// Close everything
|
||||
$xw->stop();
|
||||
|
||||
// Destroy the structure. It helps PHP 5.2 memory a lot!
|
||||
$structure->destroy();
|
||||
}
|
||||
|
||||
// Protected API starts here
|
||||
|
|
|
@ -50,6 +50,15 @@ abstract class base_final_element extends base_atom {
|
|||
$this->parent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy all circular references. It helps PHP 5.2 a lot!
|
||||
*/
|
||||
public function destroy() {
|
||||
// No need to destroy anything recursively here, direct reset
|
||||
$this->attributes = array();
|
||||
$this->parent = null;
|
||||
}
|
||||
|
||||
protected function set_parent($element) {
|
||||
if ($this->parent) {
|
||||
$info = new stdClass();
|
||||
|
|
|
@ -59,6 +59,28 @@ abstract class base_nested_element extends base_final_element {
|
|||
$this->used[] = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy all circular references. It helps PHP 5.2 a lot!
|
||||
*/
|
||||
public function destroy() {
|
||||
// Before reseting anything, call destroy recursively
|
||||
foreach ($this->children as $child) {
|
||||
$child->destroy();
|
||||
}
|
||||
foreach ($this->final_elements as $element) {
|
||||
$element->destroy();
|
||||
}
|
||||
if ($this->optigroup) {
|
||||
$this->optigroup->destroy();
|
||||
}
|
||||
// Everything has been destroyed recursively, now we can reset safely
|
||||
$this->children = array();
|
||||
$this->final_elements = array();
|
||||
$this->optigroup = null;
|
||||
// Delegate to parent to destroy other bits
|
||||
parent::destroy();
|
||||
}
|
||||
|
||||
protected function get_used() {
|
||||
return $this->used;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue