Bug #68270 [NEW]: Exception from finally block has exception from try block magically injected
| From: | dan dot lugg at gmail dot com | Date: | Mon, 20 Oct 2014 16:48:27 +0000 |
| Subject: | Bug #68270 [NEW]: Exception from finally block has exception from try block magically injected | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-188202@lists.php.net to get a copy of this message | ||
From: dan dot lugg at gmail dot com
Operating system: Windows 7 x64
PHP version: 5.5.18
Package: *General Issues
Bug Type: Bug
Bug description:Exception from finally block has exception from try block magically injected
Description:
------------
When an exception is thrown from a
finally block, if an exception has
been thrown from the finally's corresponding try block, the
finally-thrown exception magically has the try-thrown exception
assigned as it's $previous.
Test script:
---------------
<?php
try {
try {
throw new Exception('Foo');
}
finally {
throw new Exception('Bar');
}
}
catch(Exception $exception) {
var_dump($exception);
}
Expected result:
----------------
Not certain, but I'd guess the finally-thrown exception should bubble,
while the try-thrown exception is swallowed? Perhaps a different
outcome, but what occurs is both unexpected and undocumented.
Actual result:
--------------
object(Exception)#2 (7) {
["message":protected]=>
string(3) "Bar"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(9) "/in/9DMoe"
["line":protected]=>
int(8)
["trace":"Exception":private]=>
array(0) {
}
["previous":"Exception":private]=> <-- How is this here?
object(Exception)#1 (7) {
["message":protected]=>
string(3) "Foo"
["string":"Exception":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(9) "/in/9DMoe"
["line":protected]=>
int(5)
["trace":"Exception":private]=>
array(0) {
}
["previous":"Exception":private]=>
NULL
}
}
--
Edit bug report at https://bugs.php.net/bug.php?id=68270&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68270&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68270&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68270&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68270&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68270&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68270&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68270&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68270&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68270&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68270&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68270&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68270&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68270&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68270&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68270&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68270&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68270&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68270&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68270&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68270&r=mysqlcfg