Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96395 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22513 invoked from network); 17 Oct 2016 18:07:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Oct 2016 18:07:45 -0000 X-Host-Fingerprint: 176.248.3.153 unknown Received: from [176.248.3.153] ([176.248.3.153:20904] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/53-00450-07315085 for ; Mon, 17 Oct 2016 14:07:45 -0400 Message-ID: <23.53.00450.07315085@pb1.pair.com> To: internals@lists.php.net References: <010701d2218e$b2e12d60$18a38820$@belski.net> <002001d22223$23363300$69a29900$@belski.net> <025201d2259a$21e542f0$65afc8d0$@belski.net> <8d5a4bf7-3766-ae3c-400c-40b17df33a83@gmail.com> Date: Mon, 17 Oct 2016 19:07:40 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:43.0) Gecko/20100101 Firefox/43.0 SeaMonkey/2.40 MIME-Version: 1.0 In-Reply-To: <8d5a4bf7-3766-ae3c-400c-40b17df33a83@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 176.248.3.153 Subject: Re: [PHP-DEV] Regression between RC1 and RC2? From: ajf@ajf.me (Andrea Faulds) Hi Stas, Stanislav Malyshev wrote: > Hi! > >>> So the problem basically is that in PHP 7.0 both print_r and var_dump directly >>> print to output. This means that by the time the exception is thrown, we've >>> already written output. This makes it unclear how exactly the exception should >>> be handled. Is it okay to just print everything and handle the exception >>> afterward? This seems odd to me -- if an operation fails it shouldn't do anything. > > This sounds nice in theory, in practice often impossible. I.e. if you > already started printing and then some dependency fails, then you get > half-printed output. That's fine IMHO. Exception is not a normal > condition, so you get result which is not normal. > >>> In PHP 7.1 I've rewritten print_r() to use an internal buffer, so we could handle >>> this case completely gracefully. The same change could be implemented for >>> var_dump(). With this approach we'd only print anything if no exception >>> occurred. > > This is ok, but I don't think it's required. If you've got in exception > in conversion, all bets are off, any result that passes a low sanity > margin IMHO is ok - including both printing whatever happened before the > exception and not printing anything. > I also think that the exception firing mid-output isn't all that unreasonable. If you were to implement var_dump() or print_r() yourself in userland, and didn't explicitly handle this case, you'd get the same result, I imagine. -- Andrea Faulds https://ajf.me/