php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67047 weird behaviour of finally()
Submitted: 2014-04-09 09:52 UTC Modified: 2015-08-14 17:56 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: tony2001@php.net Assigned: laruence (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.5Git-2014-04-09 (Git) OS: *
Private report: No CVE-ID: None
 [2014-04-09 09:52 UTC] tony2001@php.net
Description:
------------
The following code behaves unexpectedly with finally, see the reproduce code.

Test script:
---------------
First file: 
<?php
spl_autoload_register(function(){ require_once "test1.php"; });

try {
    try {
        throw new \RuntimeException("ERROR");
    }
    finally {
        echo "AUTOLOAD", PHP_EOL;
        $q = \Test::ONE;
        echo "YOU WON'T SEE THIS LINE", PHP_EOL;
    }
}
catch (\Exception $Error) {
    echo $Error->getMessage(), PHP_EOL;
}
?>

Second file: test1.php
<?php

class Test
{
    const ONE = "ONE";
}

echo \Test::ONE, PHP_EOL;

Expected result:
----------------
The code in finally() is executed only partly: the lines after the autoload are ignored.
I would expect the result look like this:
AUTOLOAD
ONE
YOU WON'T SEE THIS LINE
ERROR

Actual result:
--------------
AUTOLOAD
ONE
ERROR


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-09 11:00 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2014-04-09 11:00 UTC] laruence@php.net
As we talked, this is a knew issue, which should be fixed in 5.6+, but due to ABI break, we can not bring the fix to 5.5...
 [2015-08-14 17:56 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2015-08-14 17:56 UTC] cmb@php.net
Obviously, this issue has been fixed as of PHP 5.6.0, see
<http://3v4l.org/CifNd>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 12:01:27 2024 UTC