From:             jdolecek at netBSD dot org
Operating system: Windows 2000
PHP version:      5.2.5
PHP Bug Type:     SimpleXML related
Bug description:  SimpleXML regression regarding empty() in 5.2.4

Description:
------------
It seems empty() on simplexml 'array' elements doesn't work same way in
5.2.5 as in 5.2.3. In 5.2.5, empty() returns true even through the elements
are actually present. Same code run under 5.2.3 works correctly, i.e.
returning true only if the element is not present.

Workaround is replace (!empty(...)) condition with isset() and test for
count(), but this is inconvenient and breaks backwards compatibility.

Reproduce code:
---------------
<?php

$str = '<?xml version="1.0" encoding="WINDOWS-1250" ?>

<config>

        <items>
                <item command="overview"/>
                <item command="deals"/>
                <item command="regions"/>
                <item command="estimations"/>
                <item command="reports"/>
                <item command="import"/>
        </items>

</config>
';

$xml = simplexml_load_string($str);

echo (empty($xml->items->item) ? "EMPTY" : "full")."\n";
echo count($xml->items->item) ."\n";


Expected result:
----------------
full
6

Actual result:
--------------
EMPTY
6

-- 
Edit bug report at http://bugs.php.net/?id=43778&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43778&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43778&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43778&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43778&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43778&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43778&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43778&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43778&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43778&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43778&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43778&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43778&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43778&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43778&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43778&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43778&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43778&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43778&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43778&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43778&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43778&r=mysqlcfg

Reply via email to