#23531 [Bgs->Opn]: Can't reset internal treenode to correctly reread xml document
| From: | bharris at spro dot net | Date: | Wed, 07 May 2003 20:42:09 +0000 |
| Subject: | #23531 [Bgs->Opn]: Can't reset internal treenode to correctly reread xml document | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-39248@lists.php.net to get a copy of this message | ||
ID: 23531
User updated by: bharris at spro dot net
Reported By: bharris at spro dot net
-Status: Bogus
+Status: Open
Bug Type: DOM XML related
Operating System: Red Hat 8.0
PHP Version: 4.3.2RC2
New Comment:
Did I report the bug incorrectly? I read both those documents prior to
reporting the bug.
I'm not relying directly on the 0 and 1 pointers, I was only using
those to expose what I think is still a bug. What I am doing is
reading a document, targeting nodes in that document, serializing those
nodes via the SESSION and then on a subsequent page reaccessing those
nodes (after reading the same document). This works fine unless I have
to reload the same document in the same script. Unfortunately not being
able to completely free (i.e. reset) the internal document skews the
objects and it errors on the next page. Is DOMELEMENT/NODE OBJECT
serialization not supported? Should I be using Xpath to
target/retarget nodes?
Previous Comments:
------------------------------------------------------------------------
[2003-05-07 15:29:17] chregu@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The internal node pointer (I assume you mean the 0 and
1 properties) were never meant to be used in PHP
Userland. Don't rely on them...
That these pointers are exposed to the outside looks is
a misconception in the domxml extension.
chregu
------------------------------------------------------------------------
[2003-05-07 13:02:03] bharris at spro dot net
--SCRIPT--
$xmlstr = '<?xml
version="1.0"?><configuration><datasources><subtree
name="Test"><apply-template
name="test.xml.com"/></subtree></datasources></configuration>';
$dom = domxml_open_mem($xmlstr);
$root = $dom->document_element();
$element = 0;
transversenodes($root, 'first');
$dom->free();
$dom = domxml_open_mem($xmlstr);
$root = $dom->document_element();
$element = 0;
transversenodes($root, 'second');
nice_r($_SESSION);
function transversenodes (&$node, $string) {
global $element;
if ($node->has_child_nodes()) {
$child = $node->child_nodes();
for ($i = 0; $i < count($child); $i++) {
if ($child[$i]->node_type() == XML_ELEMENT_NODE) {
if ($child[$i]->tagname == 'apply-template') {
$_SESSION[$string][$element] = $child[$i];
$element++;
break;
}
if ($child[$i]->tagname == 'subtree') {
$_SESSION[$string][$element] = $child[$i];
$element++;
}
transversenodes($child[$i], $string);
}
}
}
}
function nice_r (&$variable) {
echo "<pre>\n";
print_r($variable);
echo "</pre>\n";
}
--MODULES--
'./configure' '--host=i386-redhat-linux' '--build=i386-redhat-linux'
'--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr'
'--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin'
'--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include'
'--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--prefix=/usr'
'--with-config-file-path=/etc' '--enable-force-cgi-redirect'
'--disable-debug' '--enable-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-bz2' '--with-curl'
'--with-dom=/usr' '--with-exec-dir=/usr/bin'
'--with-freetype-dir=/usr'
'--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf'
'--with-ttf'
'--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp'
'--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl'
'--with-png'
'--with-pspell' '--with-xml' '--with-expat-dir=/usr'
'--with-zlib'
'--with-layout=GNU' '--enable-bcmath' '--enable-exif'
'--enable-ftp'
'--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path'
'--enable-track-vars' '--enable-trans-sid' '--enable-yp'
'--enable-wddx' '--without-oci8' '--with-pear=/usr/share/pear'
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos=/usr/kerberos'
'--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared'
'--with-snmp=shared,/usr' '--with-snmp=shared'
'--enable-ucd-snmp-hack'
'--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath'
'--enable-shmop' '--enable-versioning' '--enable-calendar'
'--enable-dbx' '--enable-dio' '--enable-mcal'
'--with-apxs2=/usr/sbin/apxs'
--COMMENTS--
I appologize for the length of the test script but I couldn't trim it
any more to show my point
My problem is that I can't reset the internal namespace for DOMXML
documents unless I load a new page (i.e. can't reset the dom space
within a single script). I need to have access to functions that will
do whatever is done between page loads because that successfully resets
the internal treenode pointer. I need to be able to load a document
into an internal treenode, modify it, write it to file then display a
graphical hyperlinked representation of the modified treenode on the
same "page". Without being able to reset the internal treenode my
serialized objects don't point at the correct object on the next page
and I get an error. Reclicking the same hyperlink at this point works
because ending the script the first time resets the internal treenode
correctly. I thought $dom->free() would work but it appears it's not,
if you run my script you'll see that the object id's are different for
the second dom object even though it's the same document, just
reloaded.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23531&edit=1