Skip to content

Commit 1e3d918

Browse files
authored
1 parent 42336e1 commit 1e3d918

15 files changed

+44
-17
lines changed

NEWS

+1
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

+2
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

+5-5
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

+2
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

+2
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

+2
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

+2
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

+1-1
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

+2
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

+7-7
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--

Zend/zend_builtin_functions.c

+5
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,11 @@ ZEND_FUNCTION(trigger_error)
12141214

12151215
switch (error_type) {
12161216
case E_USER_ERROR:
1217+
zend_error(E_DEPRECATED, "Passing E_USER_ERROR to trigger_error() is deprecated since 8.4,"
1218+
" throw an exception or call exit with a string message instead");
1219+
if (UNEXPECTED(EG(exception))) {
1220+
RETURN_THROWS();
1221+
}
12171222
case E_USER_WARNING:
12181223
case E_USER_NOTICE:
12191224
case E_USER_DEPRECATED:

ext/standard/tests/streams/gh8409.phpt

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GH-8409: Error in socket creation when error handler does not clean persistent c
33
--FILE--
44
<?php
55
set_error_handler(function (int $errno, string $errstring): never {
6-
trigger_error($errstring, E_USER_ERROR);
6+
throw new Exception($errstring);
77
});
88

99
register_shutdown_function(function (): void {
@@ -21,5 +21,10 @@ stream_socket_client('tcp://9999.9999.9999.9999:9999', $error_code, $error_messa
2121
echo "ERROR: this should not be visible\n";
2222
?>
2323
--EXPECTF--
24-
Fatal error: stream_socket_client(): %s in %sgh8409.php on line %d
24+
Fatal error: Uncaught Exception: stream_socket_client(): %s in %sgh8409.php:%d
25+
Stack trace:
26+
#0 [internal function]: {closure:%s:%d}(2, 'stream_socket_c...', '%s', %d)
27+
#1 %s(%d): stream_socket_client('tcp://9999.9999...', 0, '', 0.2, 5)
28+
#2 {main}
29+
thrown in %s on line %d
2530
OK: persistent stream closed

ext/zend_test/tests/observer_error_02.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ echo 'You should not see this.';
2626
<!-- init trigger_error() -->
2727
<trigger_error>
2828

29+
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
30+
2931
Fatal error: Foo error in %s on line %d
3032
</trigger_error:NULL>
3133
</foo:NULL>

ext/zend_test/tests/observer_error_05.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ echo 'You should not see this.';
3535
<!-- init trigger_error() -->
3636
<trigger_error>
3737

38+
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
39+
3840
Fatal error: Foo error in %s on line %d
3941
</trigger_error:NULL>
4042
</{closure:%s:%d}:NULL>

tests/lang/error_2_exception_001.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ try {
3030
}
3131

3232
try {
33-
trigger_error("I will become an exception", E_USER_ERROR);
33+
trigger_error("I will become an exception", E_USER_WARNING);
3434
} catch (MyException $exception) {
3535
echo "There was an exception: " . $exception->getErrno() . ", '" . $exception->getErrmsg() . "'\n";
3636
}
3737

3838
?>
3939
--EXPECT--
40-
There was an exception: 256, 'I will become an exception'
40+
There was an exception: 512, 'I will become an exception'

0 commit comments

Comments
 (0)