From 60465287445f546ea85ee12827772c06055984f7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 1 Dec 2009 10:01:36 -0500 Subject: [PATCH] Moving XmlNode::__killParent() to a protected method so Xml can access 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 --- cake/libs/xml.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 475caaf1993..574bfe2bb9c 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -110,7 +110,6 @@ function __construct($name = null, $value = null, $namespace = null) { $this->createTextNode($value); } } - /** * Adds a namespace to the current node * @@ -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); } } } @@ -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