From: evert at rooftopsolutions dot nl
Operating system: OS X 10.8
PHP version: 5.4.11
Package: XML Reader
Bug Type: Bug
Bug description:XMLReader does not suppress errors.
Description:
------------
Hi!
I would expect XML parsing errors to be suppressed when calling the
XMLReader::xml() with the LIBXML_NOERROR and LIBXML_NOWARNING options
passed.
In addition, libxml_get_errors() also does not get populated with any xml
errors regardless of the settings used.
This makes it very hard to catch errors in an OOP-friendly way. The only
true option to handle errors, is to use set_error_handler(), but this is a
bad practice for libraries to use, as this modifies a global state.
Using libxml_use_internal_errors(true); has no further effect.
Test script:
---------------
<?php
$xml = <<<XML
<?xml version="1.0"?>
<rootElem>
XML;
libxml_use_internal_errors(true);
$reader = new XMLReader();
$reader->xml($xml, null, LIBXML_NOERROR | LIBXML_NOWARNING);
$reader->read();
print_r(libxml_get_errors());
Expected result:
----------------
No PHP errors thrown, and an error showing up in print_r
Actual result:
--------------
PHP Warning: XMLReader::read(): An Error Occured while reading in
/Users/evert/code/xml/errortest.php on line 11
PHP Stack trace:
PHP 1. {main}() /Users/evert/code/xml/errortest.php:0
PHP 2. XMLReader->read() /Users/evert/code/xml/errortest.php:11
Warning: XMLReader::read(): An Error Occured while reading in
/Users/evert/code/xml/errortest.php on line 11
Call Stack:
0.0003 226624 1. {main}() /Users/evert/code/xml/errortest.php:0
0.0005 227616 2. XMLReader->read()
/Users/evert/code/xml/errortest.php:11
Note that when the LIBXML constants, and libxml_use_internal_errors() are
not used, a 4 distinct PHP warnings are thrown. This would suggest that
libxml errors are indeed suppressed; but there's an error mechanism in
XMLReader as well.
--
Edit bug report at https://bugs.php.net/bug.php?id=64230&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=64230&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=64230&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=64230&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64230&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64230&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64230&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64230&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64230&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64230&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64230&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=64230&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=64230&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64230&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64230&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64230&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64230&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64230&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64230&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64230&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64230&r=mysqlcfg