Bug #80063 [Opn->Ana]: XMLReader not suppressing warnings

From: Date: Thu, 01 Apr 2021 11:31:51 +0000
Subject: Bug #80063 [Opn->Ana]: XMLReader not suppressing warnings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233119@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
 Updated by:         cmb@php.net
 Reported by:        pmishev at gmail dot com
 Summary:            XMLReader not suppressing warnings
-Status:             Open
+Status:             Analyzed
 Type:               Bug
 Package:            XML Reader
 Operating System:   Ubuntu 18.04
 PHP Version:        7.3.22
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[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


Thread (4 messages)

« previous php.bugs (#233119) next »