From:             php at xmlnode dot com
Operating system: Debian
PHP version:      5.1.2
PHP Bug Type:     SimpleXML related
Bug description:  simplexml_load_file throws multiple errors making 
track_errors ineffective

Description:
------------
when simplexml_load_file fails (because the target xml file is empty for
example) there are multiple, basically useless, errors reported that makes
track_errors and $php_errormsg ineffective

My workaround has been to load the file using dom and grab it's relevant
error message then use interop to switch to simple if everything is ok...
definitely sub-optimal.

Reproduce code:
---------------
<?php
//the easiest test is to create an empty file called empty.xml

error_reporting(2047);
ini_set('display_errors',0);
ini_set('track_errors',1);

if( ! $x = simplexml_load_file('empty.xml') ){
        echo $php_errormsg;
}
?>

Expected result:
----------------
either:

"empty.xml:1: parser error : Document is empty"

or:

"empty.xml:1: parser error : Start tag expected, '<' not found"

Actual result:
--------------
"^"

If you enable display_errors you'll see that there are 3 warnings for each
'error' ("Document is empty" and "Start tag expected")  There's the
relevant error, then an empty error message and then the last one where
the message is just "^" and because that's the last one, that's the one
stored in $php_errormsg.



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

Reply via email to