Bug #72948 [Opn]: Uncatchable "Catchable" fatal error for class to string conversions
| From: | cmb@php.net | Date: | Fri, 26 Aug 2016 17:28:14 +0000 |
| Subject: | Bug #72948 [Opn]: Uncatchable "Catchable" fatal error for class to string conversions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203593@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72948&edit=1
ID: 72948
Updated by: cmb@php.net
Reported by: fredrik at neam dot se
Summary: Uncatchable "Catchable" fatal error for class to
string conversions
Status: Open
Type: Bug
-Package: *Programming Data Structures
+Package: Scripting Engine problem
PHP Version: 7.1.0beta3
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
> This results in confusion regarding whether or not PHP7's new
> ability to catch these fatal errors work or not.
The issue is not the catching of the exception, but rather that in
this case no exception is thrown at all; instead a classic
E_RECOVERABLE error is raised; otherwise you'd see a stack trace.
@nikic Has this case[1] been deliberately omitted, or has it just
been overlooked?
[1] <https://github.com/php/php-src/blob/PHP-7.1.0beta3/Zend/zend_operators.c#L889>
Previous Comments:
------------------------------------------------------------------------
[2016-08-26 13:48:53] fredrik at neam dot se
Removed operating system value since this is likely not OS-specific
------------------------------------------------------------------------
[2016-08-26 13:44:29] fredrik at neam dot se
Description:
------------
When attempting to convert a class to a string, the resulting "Catchable" fatal error is
not being caught.
This results in confusion regarding whether or not PHP7's new ability to catch these fatal
errors work or not. It turns out that some catchable fatal errors indeed can be caught, while some
don't, like the one being reported here.
This has been confirmed using the below test script against all active php and hhvm versions:
https://3v4l.org/GeNpF
Test script:
---------------
<?php
echo "PHP Version: " . PHP_VERSION . "\n";
try {
$v = new DateTime();
$v = (string) $v;
} catch (Error $e) {
echo "Caught 'Catchable fatal error' with message: " . $e->getMessage();
die();
}
echo "Did not catch 'Catchable fatal error'";
Expected result:
----------------
The Catchable fatal error should be caught
Actual result:
--------------
The Catchable fatal error is acting like a non-catchable fatal error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72948&edit=1