Bug #61335 [Com]: Access to array node returns wrong truth value
| From: | cschneid at cschneid dot com | Date: | Tue, 13 Mar 2012 13:50:26 +0000 |
| Subject: | Bug #61335 [Com]: Access to array node returns wrong truth value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-168401@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61335&edit=1
ID: 61335
Comment by: cschneid at cschneid dot com
Reported by: mueller at relog dot ch
Summary: Access to array node returns wrong truth value
Status: Open
Type: Bug
Package: SimpleXML related
Operating System: Linux
PHP Version: 5.4.0
Block user comment: N
Private report: N
New Comment:
It seems commit 311171 broke it:
http://svn.php.net/viewvc/php/php-src/branches/PHP_5_4/ext/simplexml/simplexml.c?r1=311171&r2=311170&pathrev=311171
Previous Comments:
------------------------------------------------------------------------
[2012-03-13 13:19:01] mueller at relog dot ch
The other bug is said to have been fixed in svn, however my bug still happens in
the current version from svn.
------------------------------------------------------------------------
[2012-03-10 00:00:29] me at ktamura dot com
I think this bug is related to https://bugs.php.net/bug.php?id=51615
------------------------------------------------------------------------
[2012-03-09 18:00:28] mueller at relog dot ch
I forgot: Omitting the [0] array access will also fix the problem.
------------------------------------------------------------------------
[2012-03-09 17:57:50] mueller at relog dot ch
Description:
------------
When accessing a simplexml node as array, I always get an empty simplexml object.
If I cast the node to string, the behaviour is correct.
If the parent node contains nothing but the child node (not even a newline) then
the behaviour is also correct.
Under php 5.3, the behaviour is correct.
Test script:
---------------
$rec1 = simplexml_load_string("<foo><bar>aa</bar>\n</foo>");
$rec2 = simplexml_load_string("<foo><bar>aa</bar></foo>");
if ($rec1->bar[0]) echo "NONEMPTY1\n"; # not reached, bug
if ($rec1->bar[0] . "") echo "NONEMPTY2\n"; # correct
if ($rec2->bar[0]) echo "NONEMPTY3\n"; # correct
Expected result:
----------------
NONEMPTY1
NONEMPTY2
NONEMPTY3
Actual result:
--------------
NONEMPTY2
NONEMPTY3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61335&edit=1