Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103531 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35147 invoked from network); 29 Nov 2018 13:35:33 -0000 Received: from unknown (HELO poczta.brzuchalski.com) (188.165.245.118) by pb1.pair.com with SMTP; 29 Nov 2018 13:35:33 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 7AE762984239 for ; Thu, 29 Nov 2018 10:59:39 +0100 (CET) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eg0UR6vacUWJ for ; Thu, 29 Nov 2018 10:59:35 +0100 (CET) Received: from mail-lj1-f180.google.com (unknown [209.85.208.180]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id B91AE2984233 for ; Thu, 29 Nov 2018 10:59:35 +0100 (CET) Received: by mail-lj1-f180.google.com with SMTP id g11-v6so1183000ljk.3 for ; Thu, 29 Nov 2018 01:59:35 -0800 (PST) X-Gm-Message-State: AA+aEWYGpVBYInqD2K9OtT9jYJ9QKN3qDIFD7VDCnQhZwmew6Vubi0Cx SXJ9Mq4eirbMfOYbPM9Mr2GAAJtdO7jpy63DV9M= X-Google-Smtp-Source: AFSGD/UhaD5JoW2Zjf91QF/nXftwtqmWIhMNGRVgixoA4heyaciwxbpIyL01N8SINafc4RIFggAdGXui0mqBBBpn87c= X-Received: by 2002:a2e:9819:: with SMTP id a25-v6mr697412ljj.6.1543485575088; Thu, 29 Nov 2018 01:59:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 29 Nov 2018 10:59:22 +0100 X-Gmail-Original-Message-ID: Message-ID: To: fwentish@gmail.com Cc: Nikita Popov , PHP Internals List Content-Type: multipart/alternative; boundary="0000000000006b51fb057bcabdf0" Subject: Re: [PHP-DEV] Don't silence fatal errors From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --0000000000006b51fb057bcabdf0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I don't really know if it fits here but some weeks ago I was thinking about annotations with "@" prefix and was considering to propose to handle @ (silence operator) similar way as annotations, like: $value =3D @ fopen('test.txt','rb+'); might be equivalent to: $value =3D @SupressError(E_ALL) fopen('test.txt','rb+'); BTW This way I believe it would be easier to parse annotations with '@' prefix in all desired places with one branch inside parser. As well as there will be a place to put supression error level per function/method call with more specific requirements, like: $value =3D @SupressError(E_ALL ^ E_ERROR) fopen('test.txt','rb+'); Which might work as supress all errors except fatal errors. Does that sound like a solution at all? The developer then has full controll on what errors are supressed or not. Sorry to bother you if it's insane and crazy idea. czw., 29 lis 2018 o 05:44 Fwentish Aelondes napisa=C5= =82(a): > Breaking BC might be unnecessary if instead of changing the default > behavior of @, you add an additional flag to error_reporting that > enables the new behavior, something like E_UNSILENCE_FATAL. Then > developers would only need to switch a flag in php.ini to get the old > behavior back, instead of re-working existing code around the new > behavior. > > On 11/26/18, Nikita Popov wrote: > > Hi internals, > > > > When the silencing operator @ is used, the intention is generally to > > silence expected warnings or notices. However, it currently also silenc= es > > fatal errors. As fatal errors also abort request execution, the result > will > > often be a hard to debug white screen of death. > > > > The most recent occurrence which motivated me to write this mail is > > https://bugs.php.net/bug.php?id=3D77205, but I've seen this play out > multiple > > times already. > > > > I would like to propose to change the behavior of @ to only silence > > warnings, notices and other low-level diagnostics, but leave fatal erro= rs > > intake. In particular, the following should not be silenced: > > > > * E_ERROR > > * E_CORE_ERROR > > * E_COMPILE_ERROR > > * E_USER_ERROR > > * E_RECOVERABLE_ERROR > > * E_PARSE > > > > This change would have two main implications for backwards compatibilit= y: > > > > 1. Code that legitimately wants to silence fatal errors for whatever > reason > > should now use error_reporting() (or ini_set()) to do so, instead of @. > > > > 2. Error handlers that want to only handle non-silenced errors may have > to > > be adjusted. A common pattern I found in our own tests if checks for > > error_reporting() !=3D 0 to detect silencing. This should be changed to > > error_reporting() & $err_no to detect whether the specific error type i= s > > silenced. > > > > A preliminary patch for this change is available at > > https://github.com/php/php-src/pull/3685. > > > > What do you think about this? > > > > Nikita > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --0000000000006b51fb057bcabdf0--