Skip to content

Commit

Permalink
Moving XmlNode::__killParent() to a protected method so Xml can acces…
Browse files Browse the repository at this point in the history
…s it. Adding _killParent(true) call to Xml::__destruct. Forces destruction of circular references held in child objects when an xml object is garbage collected. Fixes #369
  • Loading branch information
markstory committed Dec 1, 2009
1 parent cd46f4d commit 6046528
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cake/libs/xml.php
Expand Up @@ -110,7 +110,6 @@ function __construct($name = null, $value = null, $namespace = null) {
$this->createTextNode($value);
}
}

/**
* Adds a namespace to the current node
*
Expand Down Expand Up @@ -732,13 +731,13 @@ function __toString() {
* if given the $recursive parameter.
*
* @param boolean $recursive Recursively delete elements.
* @access private
* @access protected
*/
function __killParent($recursive = true) {
function _killParent($recursive = true) {
unset($this->__parent, $this->_log);
if ($recursive && $this->hasChildren()) {
for ($i = 0; $i < count($this->children); $i++) {
$this->children[$i]->__killParent(true);
$this->children[$i]->_killParent(true);
}
}
}
Expand Down Expand Up @@ -1093,6 +1092,7 @@ function __destruct() {
if (is_resource($this->__parser)) {
xml_parser_free($this->__parser);
}
$this->_killParent(true);
}
/**
* Adds a namespace to any XML documents generated or parsed
Expand Down

0 comments on commit 6046528

Please sign in to comment.