php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81425 exit being ignored in loops
Submitted: 2021-09-08 12:56 UTC Modified: 2021-09-08 14:05 UTC
From: Kai dot Habel at duofaktur dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 8.0.10 OS: Centos 8
Private report: No CVE-ID: None
 [2021-09-08 12:56 UTC] Kai dot Habel at duofaktur dot de
Description:
------------
Prior to php 8.0 calls to exit or die worked within loops like foreach or switch.
Since 8.0 these statements are totally ignored and this is causing hours and hours of work to use a goto call to end processing in each and every php file.

Test script:
---------------
$a = 2;
switch($a)
{
    case 1:
        echo "1";
        exit;
        break;
    case 2:
        echo "2";
        exit;
        break;
    case 3:
        echo "3";
        exit;
        break;
}
echo "4";

Expected result:
----------------
1

Actual result:
--------------
14

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-09-08 12:58 UTC] girgias@php.net
-Status: Open +Status: Feedback
 [2021-09-08 12:58 UTC] girgias@php.net
That's not true, see:
https://3v4l.org/WZFU1
 [2021-09-08 13:07 UTC] cmb@php.net
Do you use uopz?
 [2021-09-08 13:10 UTC] Kai dot Habel at duofaktur dot de
-Status: Feedback +Status: Open
 [2021-09-08 13:10 UTC] Kai dot Habel at duofaktur dot de
We do in fact have this issue and are working around this for 3 days now with multiple developers. OS : Centos 7, Remi-Safe Repo and Centos 7/8 Plesk Repo. All systems are running in this issue.
 [2021-09-08 13:24 UTC] Kai dot Habel at duofaktur dot de
No, we are not using uopz
 [2021-09-08 13:41 UTC] sjon@php.net
-Status: Open +Status: Feedback
 [2021-09-08 13:41 UTC] sjon@php.net
so what extensions do you use? I find it highly unlikely your Test script outputs `14` as reported (esp since $a=2). Can you try running with `php -n` to ensure you disable any extensions?
 [2021-09-08 13:53 UTC] Kai dot Habel at duofaktur dot de
-Status: Feedback +Status: Closed
 [2021-09-08 13:53 UTC] Kai dot Habel at duofaktur dot de
Problem solved. For whatever reason uopz was installed. Removed it and problem was gone. Thanks a lot.
 [2021-09-08 14:05 UTC] cmb@php.net
-Status: Closed +Status: Not a bug
 [2021-09-08 14:05 UTC] cmb@php.net
If you need uopz for your test suite, I suggest to set
uopz.exit=1[1], and to call uopz_allow_exit(false) in the test
suite's bootstrap.

[1] <https://www.php.net/manual/en/uopz.configuration.php#ini.uopz.exit>
 [2021-09-10 15:50 UTC] php at example dot org
WTH is that crazy extension which disables exit by default? oO
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed May 25 09:05:45 2022 UTC