Bug #72948 [NEW]: Uncatchable "Catchable" fatal error for class to string conversions
| From: | fredrik at neam dot se | Date: | Fri, 26 Aug 2016 13:44:34 +0000 |
| Subject: | Bug #72948 [NEW]: Uncatchable "Catchable" fatal error for class to string conversions | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-203580@lists.php.net to get a copy of this message | ||
From: fredrik at neam dot se
Operating system: linux
PHP version: 7.1.0beta3
Package: *Programming Data Structures
Bug Type: Bug
Bug description:Uncatchable "Catchable" fatal error for class to string conversions
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 bug report at https://bugs.php.net/bug.php?id=72948&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72948&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72948&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72948&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72948&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72948&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72948&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72948&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72948&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72948&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72948&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72948&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72948&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72948&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72948&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72948&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72948&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72948&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72948&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72948&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72948&r=mysqlcfg