ID: 46048
User updated by: php at isnoop dot net
Reported By: php at isnoop dot net
Status: Bogus
Bug Type: SimpleXML related
Operating System: Ubuntu 8.04 server
-PHP Version: 5.3.0alpha2
+PHP Version: 5.3.0alpha3
New Comment:
I have tested this with the two new PHP releases on yet another
server:
5.3.0alpha3 Fails:
[] [EMAIL PROTECTED]:~/src/php-5.3.0alpha3/sapi/cli] ./php -v;./php
~/sandbox/bug46048.php
PHP 5.3.0alpha3 (cli) (built: Dec 4 2008 17:18:52)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies
Array
(
[key] => value
)
5.2.8 Passes:
[] [EMAIL PROTECTED]:~/src/php-5.2.8/sapi/cli] ./php -v;./php
~/sandbox/bug46048.php
PHP 5.2.8 (cli) (built: Dec 8 2008 17:34:28)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
Array
(
[EMAIL PROTECTED] => Array
(
[id] => 1
)
[key] => value
)
Previous Comments:
------------------------------------------------------------------------
[2008-11-17 21:27:47] php at isnoop dot net
It appears that you're testing against 5.2.7 which I've verified
doesn't exhibit this error. This problem only appears with the 5.3.0
releases.
Both the 5.2.* releases and 5.3.* use libxml 2.6.31 on my primary test
machine. It is possible that libxml is part of the problem, but it
still stands that the problem does not manifest prior to 5.3.
------------------------------------------------------------------------
[2008-11-17 09:49:46] [EMAIL PROTECTED]
$ php t.php
Array
(
[EMAIL PROTECTED] => Array
(
[id] => 1
)
[key] => value
)
[EMAIL PROTECTED] ~]$ php -v
PHP 5.2.7-dev (cli) (built: Oct 9 2008 16:54:00) (DEBUG)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
So still no bug. If you experience this even with proper XML, I guess
it's your libxml that is a buggy version. (my PHP is build with libxml
2.7.2)
------------------------------------------------------------------------
[2008-11-11 21:51:58] php at isnoop dot net
Thank you for that. Reproduce code should be as follows:
$xml = '
<data id="1">
<key>value</key>
</data>
';
$obj = simplexml_load_string($xml);
print_r(get_object_vars($obj));
------------------------------------------------------------------------
[2008-11-11 10:50:33] [EMAIL PROTECTED]
Your xml is invalid:
$ php -n t.php
Warning: simplexml_load_string(): Entity: line 3: parser error :
Opening and ending tag mismatch: key line 3 and name in
/home/jani/src/build/php_5_3_tst/t.php on line 8
Warning: simplexml_load_string(): <key>value</name> in
/home/jani/src/build/php_5_3_tst/t.php on line 8
Warning: simplexml_load_string(): ^ in
/home/jani/src/build/php_5_3_tst/t.php on line 8
With non-invalid XML I get expected result.
------------------------------------------------------------------------
[2008-09-10 23:58:49] php at isnoop dot net
Description:
------------
The @attributes for the top-level element in a SimpleXMLElement object
aren't returned as part of any iteration over the object.
Reproduced in 5.3.0alpha1 as well.
Reproduce code:
---------------
$xml = '
<data id="1">
<key>value</name>
</data>
';
$obj = simplexml_load_string($xml);
print_r(get_object_vars($obj));
Expected result:
----------------
Array
(
[EMAIL PROTECTED] => Array
(
[id] => 1
)
[key] => value
)
Actual result:
--------------
Array
(
[key] => value
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46048&edit=1