|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80063 XMLReader not suppressing warnings
Submitted: 2020-09-05 10:50 UTC Modified: 2021-04-01 12:08 UTC
From: pmishev at gmail dot com Assigned:
Status: Open Package: XML Reader
PHP Version: 7.3.22 OS: Ubuntu 18.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
28 - 23 = ?
Subscribe to this entry?

 [2020-09-05 10:50 UTC] pmishev at gmail dot com
Warnings when opening an non-existing XML file are not being suppressed.

Neither libxml_use_internal_errors(true), nor setting LIBXML_NOERROR | LIBXML_NOWARNING has any effect whatsoever.

The problem seems related to

Test script:

$xml = 'compress.zlib://inexisting_file.xml.gz';


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



Expected result:
No PHP warnings thrown, and an error showing up in print_r

Actual result:
PHP Warning:  XMLReader::open(compress.zlib://inexisting_file.xml.gz): failed to open stream: operation failed in test.php on line 8
PHP Warning:  XMLReader::open(): Unable to open source data in test.php on line 8
PHP Warning:  XMLReader::read(): Load Data before trying to read in test.php on line 10


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-04-01 11:31 UTC]
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2021-04-01 11:31 UTC]
The first warning isn't a libxml error, but rather comes from
PHP's stream layer; as such, it is unsuitable to treat it as
libxml error.

The second warning is indeed unnecessary noise (quite similar to
bug #64230).

The third warning is correct; you should make sure to check the
return value of XMLReader::open() before you proceed.
 [2021-04-01 12:08 UTC]
-Status: Analyzed +Status: Open -Assigned To: cmb +Assigned To:
 [2021-04-01 12:08 UTC]
Sigh, it's actually more complex than I thought.  If the given
protocol is statable, a silent stat is executed, and if that
fails, no attempt is made to try to open the file.  In this case
the second warning is important information.  Only if the protocol
is not statable (like compress.zlib://), there are two warnings.
Not sure what to do about that.
 [2023-07-31 09:19 UTC] MeyerJessie283778 at gmail dot com
Awesome and interesting article. Great things you’ve always shared with us. Thanks. Just continue composing this kind of post.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 03:01:28 2024 UTC