|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64230 XMLReader does not suppress errors.
Submitted: 2013-02-18 00:44 UTC Modified: 2013-02-18 05:46 UTC
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:0 (0.0%)
From: evert at rooftopsolutions dot nl Assigned:
Status: Closed Package: XML Reader
PHP Version: 5.4.11 OS: OS X 10.8
Private report: No CVE-ID:
 [2013-02-18 00:44 UTC] evert at rooftopsolutions dot nl

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:

$xml = <<<XML
<?xml version="1.0"?>


$reader = new XMLReader();
$reader->xml($xml, null, LIBXML_NOERROR | LIBXML_NOWARNING);



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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-04 09:23 UTC]
Automatic comment on behalf of mike
Log: Fixed bug #64230 (XMLReader does not suppress errors)
 [2013-10-04 09:23 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 16:02:23 2014 UTC