Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit708de1f

Browse files
Jean85nicolas-grekas
authored andcommitted
Add regression test case for#26438
1 parent011c50c commit708de1f

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
Test that, when handling a fatal, we don't create a loop with a third party exception handler installed after ours
3+
--FILE--
4+
<?php
5+
6+
namespaceSymfony\Component\Debug;
7+
8+
$vendor =__DIR__;
9+
while (!file_exists($vendor.'/vendor')) {
10+
$vendor =dirname($vendor);
11+
}
12+
require$vendor.'/vendor/autoload.php';
13+
14+
class ThirdPartyExceptionHandler
15+
{
16+
privatestatic$prevErrorHandler;
17+
privatestatic$prevExceptionHandler;
18+
19+
publicstaticfunctionregister()
20+
{
21+
static::$prevErrorHandler =set_error_handler(array(__CLASS__,'handleError'));
22+
static::$prevExceptionHandler =set_exception_handler(array(__CLASS__,'handleException'));
23+
}
24+
25+
publicstaticfunctionhandleError($type,$message,$file,$line)
26+
{
27+
echo'Third party error handler' .PHP_EOL;
28+
echo'Calling previous handler:' .get_class(static::$prevErrorHandler[0]) .PHP_EOL;
29+
returncall_user_func(static::$prevErrorHandler,$type,$message,$file,$line);
30+
}
31+
32+
publicstaticfunctionhandleException($e)
33+
{
34+
echo'Third party exception handler' .PHP_EOL;
35+
echo'Calling previous handler:' .get_class(static::$prevExceptionHandler[0]) .PHP_EOL;
36+
returncall_user_func(static::$prevExceptionHandler,$e);
37+
}
38+
}
39+
40+
ErrorHandler::register();
41+
ThirdPartyExceptionHandler::register();
42+
ini_set('display_errors',1);
43+
44+
$a =null;
45+
require'inexistent_file.php';
46+
?>
47+
--EXPECTF--
48+
Third party error handler
49+
Calling previous handler: Symfony\Component\Debug\ErrorHandler
50+
%a
51+
Fatal error: main(): Failed opening required 'inexistent_file.php'%s
52+
Third party exception handler
53+
Calling previous handler: Symfony\Component\Debug\ErrorHandler

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp