#18760 [NEW]: PHP crashes on ADDING new nodes using DOM
| From: | mangeshd at telera dot com | Date: | Tue, 06 Aug 2002 17:34:56 +0000 |
| Subject: | #18760 [NEW]: PHP crashes on ADDING new nodes using DOM | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-16083@lists.php.net to get a copy of this message | ||
From: mangeshd@telera.com
Operating system: Windows 2000
PHP version: 4.2.2
PHP Bug Type: DOM XML related
Bug description: PHP crashes on ADDING new nodes using DOM
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 bug report at http://bugs.php.net/?id=18760&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18760&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18760&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18760&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18760&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18760&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18760&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18760&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18760&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18760&r=globals