Re: Regression between RC1 and RC2?
| From: | Andrea Faulds | Date: | Mon, 17 Oct 2016 18:07:40 +0000 |
| Subject: | Re: Regression between RC1 and RC2? | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96395@lists.php.net to get a copy of this message | ||
Hi Stas,
Stanislav Malyshev wrote:
Hi!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/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.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 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.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.