Edit report at https://bugs.php.net/bug.php?id=64230&edit=1

 ID:                 64230
 Updated by:         m...@php.net
 Reported by:        evert at rooftopsolutions dot nl
 Summary:            XMLReader does not suppress errors.
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            XML Reader
 Operating System:   OS X 10.8
 PHP Version:        5.4.11
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of mike
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=f6ff3a28d60c24dea2a05344d9b7eb823f09b4e5
Log: Fixed bug #64230 (XMLReader does not suppress errors)


Previous Comments:
------------------------------------------------------------------------
[2013-02-18 00:44:55] evert at rooftopsolutions dot nl

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 this bug report at https://bugs.php.net/bug.php?id=64230&edit=1

Reply via email to