Bug #81035 [Com]: file_get_contents emits not silenceable warning on http file not exists
| From: | shop1 at mokraemer dot de | Date: | Wed, 12 May 2021 09:56:34 +0000 |
| Subject: | Bug #81035 [Com]: file_get_contents emits not silenceable warning on http file not exists | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-233808@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81035&edit=1
ID: 81035
Comment by: shop1 at mokraemer dot de
Reported by: shop1 at mokraemer dot de
Summary: file_get_contents emits not silenceable warning on
http file not exists
Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: linux
PHP Version: 8.0.6
Block user comment: N
Private report: N
New Comment:
the @ operator does not work as it does in php 7.4
Previous Comments:
------------------------------------------------------------------------
[2021-05-12 09:54:06] nikic@php.net
You may wish to either suppress the warning using "@" (if you do not care about it), or
promote it to an exception using an error handler. The existing behavior will not be changed for
backwards-compatibility reasons.
------------------------------------------------------------------------
[2021-05-12 09:46:30] shop1 at mokraemer dot de
Description:
------------
file_get_contents emits a warning instead of an exception if the file does not exist!
This may be a good choice if the file is local where you can test for file existence. In case of
remote files via http, this is quite not possible.
Since the silence operator does not work anymore, this raises undesireable errors in the logs.
Test script:
---------------
file_get_contents('https://www.google.com/rss.xml');
Expected result:
----------------
do not emit warnings. Just throw exceptions!
Actual result:
--------------
the emitted warning is filling the logs and does not help!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81035&edit=1