Bug #75954 [Opn->Nab]: E_RECOVERABLE_ERROR Not Caught

From: Date: Tue, 13 Feb 2018 09:39:40 +0000
Subject: Bug #75954 [Opn->Nab]: E_RECOVERABLE_ERROR Not Caught
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213936@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75954&edit=1 ID: 75954 Updated by: nikic@php.net Reported by: johnpaulwallway at gmail dot com Summary: E_RECOVERABLE_ERROR Not Caught -Status: Open +Status: Not a bug Type: Bug Package: *General Issues Operating System: Linux: 14.04.5 LTS, Trusty Tahr PHP Version: 7.0.27 Block user comment: N Private report: N New Comment: Since PHP 7, fatal and recoverable fatal errors are used specifically in situations where throwing an exception is not possible for technical reasons. These cases will be ported to throw Error exceptions if and when the technical issues are resolved. Previous Comments: ------------------------------------------------------------------------ [2018-02-13 02:27:12] johnpaulwallway at gmail dot com Description: ------------ E_RECOVERABLE_ERROR halts the interpreter. While shutdown_function is called, one cannot handle framework shutdown, responses, and logging in an appropriate manner. E_RECOVERABLE_ERROR should be catchable by a catch( Throwable $t) or catch(ERROR $e), and finally blocks _must_ be executed. Test script: --------------- <?php $x = new stdClass(); try { echo $x; } catch (Throwable $t) { echo "Yeah, we couldn't convert that to a string. Log error and respond to client's request"; echo $t->__toString(); } finally { echo "Seriously? I must be wrong"; } Expected result: ---------------- Something like: Yeah, we couldn't convert that to a string. Log error and respond to client's request. E_RECOVERABLE_ERROR: Object of class stdClass could not be converted to string Seriously? I must be wrong Actual result: -------------- PHP Catchable fatal error: Object of class stdClass could not be converted to string in /tmp/foo.php on line 5 PHP Stack trace: PHP 1. {main}() /tmp/foo.php:0 Catchable fatal error: Object of class stdClass could not be converted to string in /tmp/foo.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75954&edit=1

« previous php.bugs (#213936) next »