Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103528 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99133 invoked from network); 29 Nov 2018 01:56:41 -0000 Received: from unknown (HELO mail-ed1-f41.google.com) (209.85.208.41) by pb1.pair.com with SMTP; 29 Nov 2018 01:56:41 -0000 Received: by mail-ed1-f41.google.com with SMTP id h50so227238ede.5 for ; Wed, 28 Nov 2018 14:20:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=PxglZ5pnZna62T9UGd1uXlCrcHH6VWQJUnJU0uY79uE=; b=Jo15XY2o0ugYNcSv7vnIK7DvhzkaSiUo9JI51wRgVB+f+CRNUf0+OPRdr7j/DH4hdd P4fLcb9181BocC0w1OvFhBpPxfpuJQPmHifN2TCNs5YZwSsCEiuR23ikZC7sOzvImNPA qWab03TzPeLiquoijiwm7JDy6Nd6jS9OK1Lc46DanXyzs6eTFzzYp6nK7AX42XXaIXKu jUMnWP2+nNpctjzBuVvLhKW2MY9URcNYzeFU6T5/0rKVphvO1FIFjqksCzZPKNqxnuhd rQf1S3g8g6civ0Rg7pSqq+i+4pucTYWM0cj1CO0ANKjLoL85aDEX3q4hlMbrfoSyp+YZ w+6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=PxglZ5pnZna62T9UGd1uXlCrcHH6VWQJUnJU0uY79uE=; b=XT5caR103+FOv/SPlwhpFgh+TI+G3i912B30pNpqslIujgeHJIPXU5VOljJWWJzXgK +WGFIwOHvGSWmEzzNoWRulmOaI9W0Tpe4dw0d2nyiWRfWD19DYTm0os5zQ14EH6RAGH1 O9VrGWZN5S4Fq/k3igNeOdkJz7BPYl9dNnmSiA/0WApkkqyoo7fhVNsdwg5Ey8aot/G2 3MUajDsZfUVqHIKIK366+8fnDraD6b978YE/Y4SdZwTHQPVu13PtUG/tB1DbgaJxWsSZ cQ0TgEjRvoJ6giWsYknXjRSCfv2eG0RqxY+U5HcfzOX7KB1XD1BNx7wfmvf4m8ii9LCv PODw== X-Gm-Message-State: AA+aEWYoLOGr1E24RRM9klJQA9fHnZzpRdyQZQdN/mRA1X7xrzvIWLN/ ox6bFnHxv5MUEpH1AcooyuUcXIoN X-Google-Smtp-Source: AFSGD/UuYB1bmbLD0T+K+ldiFXoVuqrdzSl56rilksuPUqPXBuBNITMRc5I4IOlnNncOHiZu2xaGbA== X-Received: by 2002:a50:87d9:: with SMTP id 25mr24766627edz.259.1543443639597; Wed, 28 Nov 2018 14:20:39 -0800 (PST) Received: from [192.168.0.63] (84-75-30-51.dclient.hispeed.ch. [84.75.30.51]) by smtp.gmail.com with ESMTPSA id o37sm66981edc.32.2018.11.28.14.20.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 14:20:39 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) In-Reply-To: Date: Wed, 28 Nov 2018 23:20:37 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <818C8C2C-B35C-4CFB-B23F-C97B2AD9DA94@gmail.com> References: To: Nikita Popov X-Mailer: Apple Mail (2.3445.9.1) Subject: Re: [PHP-DEV] Don't silence fatal errors From: claude.pache@gmail.com (Claude Pache) > Le 26 nov. 2018 =C3=A0 22:42, Nikita Popov a = =C3=A9crit : >=20 > Hi internals, >=20 > When the silencing operator @ is used, the intention is generally to > silence expected warnings or notices. However, it currently also = silences > fatal errors. As fatal errors also abort request execution, the result = will > often be a hard to debug white screen of death. >=20 > 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. >=20 > I would like to propose to change the behavior of @ to only silence > warnings, notices and other low-level diagnostics, but leave fatal = errors > intake. In particular, the following should not be silenced: >=20 > * E_ERROR > * E_CORE_ERROR > * E_COMPILE_ERROR > * E_USER_ERROR > * E_RECOVERABLE_ERROR > * E_PARSE >=20 > This change would have two main implications for backwards = compatibility: >=20 > 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 = @. >=20 > 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 = is > silenced. >=20 > A preliminary patch for this change is available at > https://github.com/php/php-src/pull/3685. >=20 > What do you think about this? >=20 > Nikita Although this can be viewed as an issue of the silencing operator, this = can also be viewed as an issue of the default error handler, which = should not blindly obey the error_reporting() directive (or the @ = operator) in case of fatal error. Hopefully, custom error handlers are able to scream even when they are = asked to shut up. My suggestion is rather to change the implementation of the default = error handler, so that it refuses to ever sweep fatal error messages = under the rug. Code that has legitimate reasons to silence fatal errors = can always use a custom error handler that will obey it. (BTW, it could be handy to have the following built-in constant: const E_ANY_ERROR =3D E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | = E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE; and ditto for warnings and notices.) =E2=80=94Claude