Skip to content

Commit 8ca2f71

Browse files
committed
Merge branch 'PHP-8.6'
* PHP-8.6: fibers: fix GH-23921 (Fibers start with error_reporting = 0 when the error_reporting INI directive is not set)
2 parents f6b6bfa + 3bb50c1 commit 8ca2f71

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

‎Zend/tests/fibers/gh23921.phpt‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
GH-23921 (Fibers start with error_reporting = 0 when the error_reporting INI directive is not set)
3+
--FILE--
4+
<?php
5+
echo error_reporting(), "\n";
6+
(new Fiber(function () {
7+
echo error_reporting(), "\n";
8+
echo $undefined;
9+
echo "after\n";
10+
}))->start();
11+
?>
12+
--EXPECTF--
13+
30719
14+
30719
15+
16+
Warning: Undefined variable $undefined in %s on line 5
17+
after
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Silence operator must not change the error_reporting value within the fiber
3+
--FILE--
4+
<?php
5+
6+
error_reporting(E_WARNING);
7+
8+
@(new Fiber(function () {
9+
var_dump(E_ALL);
10+
var_dump(E_WARNING);
11+
var_dump(error_reporting());
12+
}))->start();
13+
14+
?>
15+
--EXPECT--
16+
int(30719)
17+
int(2)
18+
int(2)

‎Zend/zend_fibers.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,9 @@ static ZEND_STACK_ALIGNED void zend_fiber_execute(zend_fiber_transfer *transfer)
570570

571571
zend_fiber *fiber = EG(active_fiber);
572572

573-
/* Determine the current error_reporting ini setting. */
573+
/* We cannot rely on EG(error_reporting) as a silence operator @ may modify the executor global error_reporting
574+
* value without changing the underlying INI value */
574575
zend_long error_reporting = zend_ini_long_literal("error_reporting");
575-
/* If error_reporting is 0 and not explicitly set to 0, zend_ini_str returns a null pointer. */
576-
if (!error_reporting && !zend_ini_str_literal("error_reporting")) {
577-
error_reporting = E_ALL;
578-
}
579576

580577
EG(vm_stack) = NULL;
581578

0 commit comments

Comments
 (0)