Bug #17560: dump_mem with format mangles doc for subsequent requests

From: Date: Sun, 02 Jun 2002 04:29:22 +0000
Subject: Bug #17560: dump_mem with format mangles doc for subsequent requests
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-9133@lists.php.net to get a copy of this message
From: jhpellerin@attbi.com Operating system: Linux (redhat 7.2) + Apache 1.3. PHP version: 4.2.1 PHP Bug Type: DOM XML related Bug description: dump_mem with format mangles doc for subsequent requests Calling $doc->dump_mem or $doc->dump_file with format set to true seems to corrupt the internal representation of the XML document, removing all writespace-only text nodes, which alters the structure of the document. It doesn't affect the document object in the same request, but all subsequent requests that access an identical XML doc -- even on a different page -- will see the altered structure instead of the structure actually present in the original doc. Workaround: set format to false Config: './configure' '--with-apxs=/opt/apache/bin/apxs' '--with-dom' '-with-dom-xslt' '--with-dom-exslt' '--prefix=/opt' '--with-zlib' Demo script: <?php $xml = "<?xml version=\"1.0\"?> <motel> <roaches> <roach state=\"alive\"/> <roach state=\"dead\"/> <roach state=\"dead\"/> </roaches> </motel>"; $doc = domxml_open_mem($xml); echo "First listing:<br>\n"; list_roaches($doc); /* Calling dump mem with format set to true alters the in-memory copy the xml file, even across reloads of the page! With the whitespace stripped, the structure of the document changes. */ $foo = $doc->dump_mem(true); echo "After doc->dump_mem called:<br>\n"; list_roaches($doc); echo "Now, reload to see error<br>\n"; function list_roaches ($doc) { $root = $doc->document_element(); $first_child = $root->first_child(); $roaches_el = $first_child->next_sibling(); if ($roaches_el) { $roaches_list = $roaches_el->get_elements_by_tagname("roach"); for ($i = 0; $i < count($roaches_list); $i++) { echo " Roach $i is " . $roaches_list[$i]->get_attribute("state") . "<br>\n"; } } else { echo "No sibling of first child found!<br><xmp>\n"; echo $doc->dump_mem(); echo "</xmp>\n"; } } ?> -- Edit bug report at http://bugs.php.net/?id=17560&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=17560&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=17560&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=17560&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=17560&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=17560&r=support Expected behavior: http://bugs.php.net/fix.php?id=17560&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=17560&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=17560&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=17560&r=globals

« previous php.bugs (#9133) next »