Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94071 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31235 invoked from network); 17 Jun 2016 09:46:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2016 09:46:19 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.20 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.20 mout.gmx.net Received: from [212.227.17.20] ([212.227.17.20:53330] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 28/C1-18862-9E6C3675 for ; Fri, 17 Jun 2016 05:46:18 -0400 Received: from [192.168.2.102] ([217.82.228.97]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0LinyL-1bpvvU2uyr-00cwAw; Fri, 17 Jun 2016 11:46:13 +0200 To: Alexander Lisachenko , PHP Internals References: <2635b3b6-b971-9fb7-5def-26b86eafb54d@fleshgrinder.com> Message-ID: <98f97016-066e-b5a4-8d1d-4bca179315fa@gmx.de> Date: Fri, 17 Jun 2016 11:46:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:UbgEE9XFe3XIKkcO/IQFjdGCRrid1Eh5xlyRSjigRDjjnpWRMvC yIrSrgXwzjLaRGS9C8rxOlP3GKSb21PbmcrqtkC27LXf219LTkQdqAcrOh14dvvpTLuxLXB 7lAqtJT+XqI7Zz9Qiy5iFy/VyhoboZ3WJQAUz9sWQ1qVL6RjvrzEo3Sfs3Sl2ihHtBy1DDk iA9M73OjfFWH6t0sUW4Fg== X-UI-Out-Filterresults: notjunk:1;V01:K0:+JcFijoyhlE=:6wnFQ+U9y4rg4doHQr8Spm 0Kkd0Plzj6/HB+/8CuAr0jKxkhO5aZC7GBCe2SEdOvIcFQfMuAJY0NBrzvzCr8QQGLShbmstz /VKzTORM3JPoj4ZLvrqffu08myAiKwZYTNHXgOuzjdxn7pJKc2ejXdISX3q3h+7XS+G+YcOSl k+/76gjvxDJ8Ony/iTqIXnwWzAiRnLPxB/JEj6SgXt5xGp65FC6OLhMgcSnBvuwtlFw1lMqJj rveWLVZdJAEpF5UbB8VffOO8ekK/KMWjFgPWXXCiZt2FcP58ofEPDlHeX5UayZTHyWfcDvXJA x2YpVtazuSfXNUiunPu4D8Xh49+2FpSu0CRRcLt3A01AzMlQhUE/MBTkd/53uQX0/M6uYv97a Wu2uK0ZWhh0JE9p7IyJm3ro8/YoM+BGSpST68YXU2vugfbuW42bCjCjwMt7VbCT9zhsSwpiI1 Pf8Ys67PCO6ua4H5Of7NTelSWUdezgAdU9djWWfJepCV3cnQJfMkeIAxpXp2b6jkX+rI1hr+l +sAstcBd0vflmGjisGnzVAcGu6XWUXTDgoPtd8VqtkH9NRTjbnrcs138VT7AfclL6XHq4WUTR YMWEPz3jNshsUGHiB+G0NCI040LmIJfH/Vw1wMi2wowMX5ThE96MPT5FE38N0iALW73B5cc38 703wAUe71bIqXjSOp2Yc3uunNYKOEVSK2G2Ep/CWnoJEdlyUKt7XVrbJcdMR59/sU9OuXSxv1 ZncBvahgJ+aY1nB9LyGHao2y9/8Nyhddr0YPsMuOH9UxfOdQ3GuO+aLENdmUSc4Ah8WVkDYb1 0x8rC5Y Subject: Re: [PHP-DEV] Throwing an Error for require expressions in PHP7.x From: cmbecker69@gmx.de (Christoph Becker) On 17.06.2016 at 10:29, Alexander Lisachenko wrote: > Nikita, Dmitry, ping. What do you think, shouldn't we replace all possible > places with Fatal Errors with correct throwing of Error exceptions? In > this concrete case it's for "require" operator. > > From what I can see Error will give us more control over the file loading > process and make it more atomic, because additional checks > if(file_exists($file) && is_readable($file)) generate extra stat commands, > they are slow and not reliable, because for highload projects, we can be in > the situation where "if" succeeded, but the "require" will fail because our > file was deleted immediately after check. > > Code like this: > try { > require $fileName; > } catch (Error $e) { > echo "Oops, maybe deleted? " . $e; > } > > is much more reliable than following, by using "include" instead of > "require". This was suggested in https://bugs.php.net/bug.php?id=72089: I have re-opened this ticket. > if (file_exists($fileName) && is_readable($fileName)) { > @include $fileName; // Silencing errors for the case of race-condition, > etc > } I'm not generally against throwing exceptions from include (or several other filesystem functions, for that matter), but the BC break has to be considered. I am, however, still opposed to offer the ability to catch a failing *require*. > Pay an attention, that we always need to put the silencing operator here to > prevent warnings, etc. This also hides all internal errors for parsing, > thanks to the PHP. And we can't easily detect the reason why include was > failed. Only possible way is to register error_handler and throw an > instance of ErrorException. > > But if require will throw an Error, nothing will changed, because unhandled > Error will produce a Fatal Error, but all modern code will be able to > handle this situation. -- Christoph M. Becker