mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-02 09:32:43 +00:00
Merge remote branch 'origin/1.2' into 1.3
This commit is contained in:
commit
3075eda8b6
2 changed files with 23 additions and 5 deletions
|
@ -691,7 +691,6 @@ class XmlNode extends Object {
|
|||
|
||||
foreach ($this->children as $child) {
|
||||
$key = $camelize ? Inflector::camelize($child->name) : $child->name;
|
||||
//debug($key);
|
||||
|
||||
if (is_a($child, 'XmlTextNode')) {
|
||||
$out['value'] = $child->value;
|
||||
|
@ -873,7 +872,7 @@ class Xml extends XmlNode {
|
|||
parent::__construct('#document');
|
||||
|
||||
if ($options['root'] !== '#document') {
|
||||
$Root = $this->createNode($options['root']);
|
||||
$Root =& $this->createNode($options['root']);
|
||||
} else {
|
||||
$Root =& $this;
|
||||
}
|
||||
|
@ -955,6 +954,8 @@ class Xml extends XmlNode {
|
|||
break;
|
||||
}
|
||||
}
|
||||
xml_parser_free($this->__parser);
|
||||
$this->__parser = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1132,9 +1133,6 @@ class Xml extends XmlNode {
|
|||
* @access private
|
||||
*/
|
||||
function __destruct() {
|
||||
if (is_resource($this->__parser)) {
|
||||
xml_parser_free($this->__parser);
|
||||
}
|
||||
$this->_killParent(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1396,5 +1396,25 @@ class XmlTest extends CakeTestCase {
|
|||
$result = $result[0]->first();
|
||||
$this->assertEqual($result->value, '012345');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that creating an xml object does not leak memory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testMemoryLeakInConstructor() {
|
||||
if ($this->skipIf(!function_exists('memory_get_usage'), 'Cannot test memory leaks without memory_get_usage')) {
|
||||
return;
|
||||
}
|
||||
$data = '<?xml version="1.0" encoding="UTF-8"?><content>TEST</content>';
|
||||
$start = memory_get_usage();
|
||||
for ($i = 0; $i <= 300; $i++) {
|
||||
$test =& new XML($data);
|
||||
$test->__destruct();
|
||||
unset($test);
|
||||
}
|
||||
$end = memory_get_usage();
|
||||
$this->assertWithinMargin($start, $end, 3600, 'Memory leaked %s');
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue