#18760 [Opn->Csd]: PHP crashes on ADDING new nodes using DOM
| From: | jtate@php.net | Date: | Tue, 06 Aug 2002 17:48:43 +0000 |
| Subject: | #18760 [Opn->Csd]: PHP crashes on ADDING new nodes using DOM | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-16085@lists.php.net to get a copy of this message | ||
ID: 18760
Updated by: jtate@php.net
Reported By: mangeshd@telera.com
-Status: Open
+Status: Closed
Bug Type: DOM XML related
Operating System: Windows 2000
PHP Version: 4.2.2
New Comment:
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a
documentation
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2002-08-06 13:34:55] mangeshd@telera.com
Following script will allow you to reproduce the bug. The script
doesn't crash when we add 100 nodes but it crashes for a bigger (500)
number of nodes. It seesms like it finishes executing all the
statements and crashes after the last one.
<?php
$xmlString = GetBaseAppXML();
if( !$xmlDoc = domxml_open_mem( $xmlString ) ) {
echo "Error while creating DOM object\n";
exit;
}
for ( $i=0; $i<500; $i++ ) {
UpdateAppXML( $xmlDoc, $i, "This" );
}
echo( $xmlDoc->dump_mem( true ));
exit;
function GetBaseAppXML() {
$strXML = '<?xml version="1.0" ?>';
$strXML = $strXML.'<XMLPage>';
$strXML = $strXML.'</XMLPage>';
return $strXML;
}
function UpdateAppXML( &$xmlDoc, $key, $value ) {
$searchStr = "//SET[@VARNAME = '".$key."']" ;
$xpathCtx = xpath_new_context( $xmlDoc );
$arrSetElem = xpath_eval( $xpathCtx, $searchStr );
$setElem = $arrSetElem->nodeset[0];
if ( is_object( $setElem ) ) {
$setElem->set_attribute( "VALUE", $value );
} else {
$searchStr = "/XMLPage" ;
$rootElem = $xmlDoc->document_element();
if ( $rootElem != null ) {
$newElem = $xmlDoc->create_element( "SET" );
$newElem->set_attribute( "VARNAME", $key );
$newElem->set_attribute( "VALUE", $value );
$newElem = $rootElem->append_child( $newElem );
unset( $newElem );
} else {
$strMsg = "UpdateAppXML :: Failed to get ROOT element in file:
".$appFilePath ;
print( "Error processing request<BR>" );
print( $strMsg );
unset( $strMsg );
}
unset( $rootElem );
}
unset( $xpathCtx );
unset( $arrSetElem );
unset( $setElem );
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18760&edit=1