Bug #80063 [Com]: XMLReader not suppressing warnings

From: Date: Mon, 31 Jul 2023 09:19:11 +0000
Subject: Bug #80063 [Com]: XMLReader not suppressing warnings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245069@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80063&edit=1 ID: 80063 Comment by: MeyerJessie283778 at gmail dot com Reported by: pmishev at gmail dot com Summary: XMLReader not suppressing warnings Status: Open Type: Bug Package: XML Reader Operating System: Ubuntu 18.04 PHP Version: 7.3.22 Block user comment: N Private report: N New Comment: Awesome and interesting article. Great things you’ve always shared with us. Thanks. Just continue composing this kind of post. (https://github.com.php)(https://www.screenmirroring.onl/how-to-screen-mirror-your-xiaomi-smartphone-to-your-pc/) Previous Comments: ------------------------------------------------------------------------ [2021-04-01 12:08:41] cmb@php.net 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. ------------------------------------------------------------------------ [2021-04-01 11:31:51] cmb@php.net 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. ------------------------------------------------------------------------ [2020-09-05 10:50:50] pmishev at gmail dot com Description: ------------ 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 https://bugs.php.net/bug.php?id=64230 Test script: --------------- <?php $xml = 'compress.zlib://inexisting_file.xml.gz'; libxml_use_internal_errors(true); $reader = new XMLReader(); $reader->open($xml, null, LIBXML_NOERROR | LIBXML_NOWARNING); $reader->read(); print_r(libxml_get_errors()); 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 Array ( ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80063&edit=1

« previous php.bugs (#245069) next »