Skip to content

Commit 1e3d918

Browse files
authored
ext/core: Deprecate passing E_USER_ERROR to trigger_error() (#15308)
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
1 parent 42336e1 commit 1e3d918

15 files changed

+44
-17
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PHP NEWS
99
. Fixed bug GH-15140 (Missing variance check for abstract set with asymmetric
1010
type). (ilutov)
1111
. Fixed bug GH-15181 (Disabled output handler is flushed again). (cmb)
12+
. Passing E_USER_ERROR to trigger_error() is now deprecated. (Girgias)
1213

1314
- Date:
1415
. Constants SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, and SUNFUNCS_RET_DOUBLE

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,8 @@ PHP 8.4 UPGRADE NOTES
401401
- Core:
402402
. Implicitly nullable parameter types are now deprecated.
403403
RFC: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types
404+
. Passing E_USER_ERROR to trigger_error() is now deprecated.
405+
RFC: https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
404406

405407
- Curl:
406408
. The CURLOPT_BINARYTRANSFER constant is deprecated.

Zend/tests/bug33802.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
Bug #33802 (throw Exception in error handler causes crash)
33
--FILE--
44
<?php
5-
set_error_handler('errorHandler', E_USER_ERROR);
6-
try{
5+
set_error_handler('errorHandler', E_USER_WARNING);
6+
try {
77
test();
8-
}catch(Exception $e){
8+
} catch(Exception $e){
99
}
1010
restore_error_handler();
1111

12-
function test(){
13-
trigger_error("error", E_USER_ERROR);
12+
function test() {
13+
trigger_error("error", E_USER_WARNING);
1414
}
1515

1616
function errorHandler($errno, $errstr, $errfile, $errline) {

Zend/tests/fibers/fatal-error-in-fiber.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ $fiber->start();
1111

1212
?>
1313
--EXPECTF--
14+
Deprecated: Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead in %s on line %d
15+
1416
Fatal error: Fatal error in fiber in %sfatal-error-in-fiber.php on line %d

Zend/tests/fibers/fatal-error-in-nested-fiber.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ $fiber->resume();
2525
int(2)
2626
int(1)
2727

28+
Deprecated: Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead in %s on line %d
29+
2830
Fatal error: Fatal error in nested fiber in %sfatal-error-in-nested-fiber.php on line %d

Zend/tests/fibers/fatal-error-with-multiple-fibers.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ $fiber2->resume();
2525
int(1)
2626
int(2)
2727

28+
Deprecated: Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead in %s on line %d
29+
2830
Fatal error: Fatal error in fiber in %sfatal-error-with-multiple-fibers.php on line %d

Zend/tests/fibers/gh10437.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ $fiber->start();
1414

1515
?>
1616
--EXPECTF--
17+
Deprecated: Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead in %s on line %d
18+
1719
Fatal error: Bailout in fiber in %sgh10437.php on line %d
1820
NULL

Zend/tests/gh10695_7.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set_error_handler(function ($errno, $errstr) {
99
throw new \Exception($errstr);
1010
});
1111
register_shutdown_function(function () {
12-
trigger_error('main', E_USER_ERROR);
12+
trigger_error('main', E_USER_WARNING);
1313
});
1414
?>
1515
--EXPECT--

Zend/tests/gh13097_a.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ trigger_error(
1212

1313
?>
1414
--EXPECTF--
15+
Deprecated: Passing E_USER_ERROR to trigger_error() is deprecated since 8.4, throw an exception or call exit with a string message instead in %s on line %d
16+
1517
Fatal error: class@anonymous%s ...now you don't! in %s on line %d

Zend/tests/nowdoc_015.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ function error_handler($num, $msg, $file, $line) {
66
echo $line,"\n";
77
}
88
set_error_handler('error_handler');
9-
trigger_error("line", E_USER_ERROR);
9+
trigger_error("line", E_USER_WARNING);
1010
$x = <<<EOF
1111
EOF;
1212
var_dump($x);
13-
trigger_error("line", E_USER_ERROR);
13+
trigger_error("line", E_USER_WARNING);
1414
$x = <<<'EOF'
1515
EOF;
1616
var_dump($x);
17-
trigger_error("line", E_USER_ERROR);
17+
trigger_error("line", E_USER_WARNING);
1818
$x = <<<EOF
1919
test
2020
EOF;
2121
var_dump($x);
22-
trigger_error("line", E_USER_ERROR);
22+
trigger_error("line", E_USER_WARNING);
2323
$x = <<<'EOF'
2424
test
2525
EOF;
2626
var_dump($x);
27-
trigger_error("line", E_USER_ERROR);
27+
trigger_error("line", E_USER_WARNING);
2828
$x = <<<EOF
2929
test1
3030
test2
@@ -34,7 +34,7 @@ test3
3434
3535
EOF;
3636
var_dump($x);
37-
trigger_error("line", E_USER_ERROR);
37+
trigger_error("line", E_USER_WARNING);
3838
$x = <<<'EOF'
3939
test1
4040
test2
@@ -44,7 +44,7 @@ test3
4444

4545
EOF;
4646
var_dump($x);
47-
trigger_error("line", E_USER_ERROR);
47+
trigger_error("line", E_USER_WARNING);
4848
echo "ok\n";
4949
?>
5050
--EXPECT--

0 commit comments

Comments
 (0)