ID:               27010
 Updated by:       [EMAIL PROTECTED]
 Reported By:      web-php-bugs at sklar dot com
-Status:           Open
+Status:           Closed
 Bug Type:         XML related
 Operating System: Linux
 PHP Version:      5CVS-2004-01-22 (dev)
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2004-01-22 14:14:05] web-php-bugs at sklar dot com

When I retrieve child elements like this:

foreach ($sxe->children('http://www.example.com/hot') as $element_name
=> $element) {
    print "$element_name is
".$element->children('http://www.example.com/hot')."\n";
}

It works fine (duh). But I still get the segfault -- backtrace in my
previous comment.

------------------------------------------------------------------------

[2004-01-22 14:13:05] web-php-bugs at sklar dot com

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076484640 (LWP 16185)]
0x080eb813 in match_ns (sxe=0x402afb74, node=0x835c910,
    name=0x835c4b8 "http://www.example.com/hot";)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:124
124             if (!xmlStrcmp(node->ns->href, name)) {
(gdb) bt
#0  0x080eb813 in match_ns (sxe=0x402afb74, node=0x835c910,
    name=0x835c4b8 "http://www.example.com/hot";)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:124
#1  0x080eb2d6 in php_sxe_move_forward_iterator (sxe=0x402afb74)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:1394
#2  0x080eb3ea in php_sxe_iterator_move_forward (iter=0x402afaec)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:1424
#3  0x082390c5 in zend_fe_fetch_handler (execute_data=0xbfffd0c0,
    op_array=0x402adb6c)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:3672
#4  0x0823221f in execute (op_array=0x402adb6c)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:1264
#5  0x08210d11 in zend_execute_scripts (type=8, retval=0x0,
file_count=3)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend.c:1051
#6  0x081ce776 in php_execute_script (primary_file=0xbffff4c0)
    at /opt/cvs/cvs.php.net/php-src/main/main.c:1642
#7  0x0824252c in main (argc=2, argv=0xbffff554)
    at /opt/cvs/cvs.php.net/php-src/sapi/cli/php_cli.c:939
#8  0x42015704 in __libc_start_main () from /lib/tls/libc.so.6
(gdb) p *node
$1 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x835c900
"drink",
  children = 0x835c968, last = 0x835c968, parent = 0x835c5d8,
  next = 0x835c9e8, prev = 0x835c8c8, doc = 0x835c4f0, ns = 0x0,
  content = 0x0, properties = 0x0, nsDef = 0x0}

------------------------------------------------------------------------

[2004-01-22 14:08:15] web-php-bugs at sklar dot com

Description:
------------
When iterating through the results of the SimpleXML children() method,
$element->name syntax returns the empty string instead of the text of
the "name" tag. var_dump($element), however reports the correct value
for the "name" property of $element.

Reproduce code:
---------------
$xml='
<drinks xmlns:hot="http://www.example.com/hot";>
 <hot:drink><hot:name>Coffee</hot:name></hot:drink>
 <hot:drink><hot:name>Tea</hot:name></hot:drink>
 <drink><name>Cola</name></drink>
 <drink><name>Juice</name></drink>
</drinks>';
 
$sxe = simplexml_load_string($xml);


foreach ($sxe as $element_name => $element) {
    print "$element_name is $element->name\n";
}

foreach ($sxe->children('http://www.example.com/hot') as $element_name
=> $element) {
    print "$element_name is $element->name\n";
}

Expected result:
----------------
drink is Cola
drink is Juice
drink is Coffee
drink is Tea


Actual result:
--------------
drink is Cola
drink is Juice
drink is
drink is
Segmentation fault

Substituting var_dump($element) for the print statement produces:

object(simplexml_element)#5 (1) {
  ["name"]=>
  string(6) "Coffee"
}
object(simplexml_element)#4 (1) {
  ["name"]=>
  string(3) "Tea"
}

[New Thread 1076484640 (LWP 16144)]
drink is Cola
drink is Juice
drink is
drink is

On the segfault, GDB reports:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076484640 (LWP 16144)]
0x080eb813 in match_ns (sxe=0x402af9d4, node=0x835c910,
    name=0x835c4b8 "http://www.example.com/hot";)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:124
124             if (!xmlStrcmp(node->ns->href, name)) {
(gdb) bt
#0  0x080eb813 in match_ns (sxe=0x402af9d4, node=0x835c910,
    name=0x835c4b8 "http://www.example.com/hot";)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:124
#1  0x080eb2d6 in php_sxe_move_forward_iterator (sxe=0x402af9d4)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:1394
#2  0x080eb3ea in php_sxe_iterator_move_forward (iter=0x402af94c)
    at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:1424
#3  0x082390c5 in zend_fe_fetch_handler (execute_data=0xbfffd5c0,
    op_array=0x402adb6c)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:3672
#4  0x0823221f in execute (op_array=0x402adb6c)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:1264
#5  0x08210d11 in zend_execute_scripts (type=8, retval=0x0,
file_count=3)
    at /opt/cvs/cvs.php.net/php-src/Zend/zend.c:1051
#6  0x081ce776 in php_execute_script (primary_file=0xbffff9c0)
    at /opt/cvs/cvs.php.net/php-src/main/main.c:1642
#7  0x0824252c in main (argc=2, argv=0xbffffa54)
    at /opt/cvs/cvs.php.net/php-src/sapi/cli/php_cli.c:939
#8  0x42015704 in __libc_start_main () from /lib/tls/libc.so.6
(gdb) p *node
$1 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x835c900
"drink",
  children = 0x835c968, last = 0x835c968, parent = 0x835c5d8,
  next = 0x835c9e8, prev = 0x835c8c8, doc = 0x835c4f0, ns = 0x0,
  content = 0x0, properties = 0x0, nsDef = 0x0}




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27010&edit=1

Reply via email to