Bug #81035 [Nab]: file_get_contents emits not silenceable warning on http file not exists

From: Date: Wed, 12 May 2021 10:00:05 +0000
Subject: Bug #81035 [Nab]: 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-233809@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 Updated by: nikic@php.net 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 no longer suppresses fatal errors in PHP 8. It does still suppress warnings, and file_get_contents() throws a warning, not a fatal error. If @ does not work as expected in PHP 8, then this might be caused by a broken custom error handler. Please search for my_error_handler on https://www.php.net/manual/en/migration80.incompatible.php for an example of the necessary change. Previous Comments: ------------------------------------------------------------------------ [2021-05-12 09:56:34] shop1 at mokraemer dot de the @ operator does not work as it does in php 7.4 ------------------------------------------------------------------------ [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

« previous php.bugs (#233809) next »