Bug #78505 [NEW]: casting stdClass to string now unrecoverable fatal error
| From: | phofstetter at sensational dot ch | Date: | Fri, 06 Sep 2019 12:02:58 +0000 |
| Subject: | Bug #78505 [NEW]: casting stdClass to string now unrecoverable fatal error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222601@lists.php.net to get a copy of this message | ||
From: phofstetter at sensational dot ch
Operating system: macOS, Debian Linux
PHP version: 7.4.0RC1
Package: *General Issues
Bug Type: Bug
Bug description:casting stdClass to string now unrecoverable fatal error
Description:
------------
In previous releases of PHP, casting instances of stdClass to string
would raise an E_RECOVERABLE_ERROR, but in 7.4, this has changed to
raise a E_ERROR fatal error.
I'm not entirely sure this increase of severity is entirely justified as
catching fatal errors in production is still annoying and hard to get
meaningful backtraces reported.
Test script:
---------------
<?php
set_error_handler(function($errno, $errstr, $errfile, $errline){
if((error_reporting() & $errno) === 0){
return true;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
try {
(string)new stdClass;
} catch (ErrorException $e){
echo "caught\n";
}
Expected result:
----------------
"caught"
Actual result:
--------------
PHP Fatal error: Uncaught Error: Object of class stdClass could not be
converted to string in /var/webapps/popscan/flupp.php:11
Stack trace:
#0 {main}
thrown in /var/webapps/popscan/flupp.php on line 11
Fatal error: Uncaught Error: Object of class stdClass could not be
converted to string in /var/webapps/popscan/flupp.php:11
Stack trace:
#0 {main}
thrown in /var/webapps/popscan/flupp.php on line 11
--
Edit bug report at https://bugs.php.net/bug.php?id=78505&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78505&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78505&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78505&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78505&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78505&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78505&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78505&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78505&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78505&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78505&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78505&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78505&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78505&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78505&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78505&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78505&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78505&r=mysqlcfg