forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed bug #61767 (Shutdown functions not called in certain error si…
…tuation) - Fixed bug #60909 (custom error handler throwing Exception + fatal error = no shutdown function)
- Loading branch information
Showing
7 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--TEST-- | ||
Bug #60909 (custom error handler throwing Exception + fatal error = no shutdown function). | ||
--FILE-- | ||
<?php | ||
register_shutdown_function(function(){echo("\n\n!!!shutdown!!!\n\n");}); | ||
set_error_handler(function($errno, $errstr, $errfile, $errline){ | ||
echo "error($errstr)"; | ||
throw new Exception("Foo"); | ||
}); | ||
|
||
require 'notfound.php'; | ||
--EXPECTF-- | ||
error(require(notfound.php): failed to open stream: No such file or directory) | ||
Warning: Uncaught exception 'Exception' with message 'Foo' in %sbug60909_1.php:5 | ||
Stack trace: | ||
#0 %sbug60909_1.php(8): {closure}(2, 'require(notfoun...', '%s', 8, Array) | ||
#1 %sbug60909_1.php(8): require() | ||
#2 {main} | ||
thrown in %sbug60909_1.php on line 5 | ||
|
||
Fatal error: main(): Failed opening required 'notfound.php' (include_path='%s') in %sbug60909_1.php on line 8 | ||
|
||
|
||
!!!shutdown!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Bug #60909 (custom error handler throwing Exception + fatal error = no shutdown function). | ||
--FILE-- | ||
<?php | ||
register_shutdown_function(function(){echo("\n\n!!!shutdown!!!\n\n");}); | ||
set_error_handler(function($errno, $errstr, $errfile, $errline){throw new Exception("Foo");}); | ||
|
||
class Bad { | ||
public function __toString() { | ||
throw new Exception('Oops, I cannot do this'); | ||
} | ||
} | ||
|
||
$bad = new Bad(); | ||
echo "$bad"; | ||
--EXPECTF-- | ||
Fatal error: Method Bad::__toString() must not throw an exception in %sbug60909_2.php on line 0 | ||
|
||
|
||
!!!shutdown!!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--TEST-- | ||
Bug #61767 (Shutdown functions not called in certain error situation) | ||
--FILE-- | ||
<?php | ||
set_error_handler(function($code, $msg, $file = null, $line = null) { | ||
echo "Error handler called ($msg)\n"; | ||
throw new \ErrorException($msg, $code, 0, $file, $line); | ||
}); | ||
|
||
register_shutdown_function(function(){ | ||
echo "Shutting down\n"; | ||
print_r(error_get_last()); | ||
}); | ||
|
||
//$undefined = null; // defined variable does not cause problems | ||
$undefined->foo(); | ||
--EXPECTF-- | ||
Error handler called (Undefined variable: undefined) | ||
|
||
Warning: Uncaught exception 'ErrorException' with message 'Undefined variable: undefined' in %sbug61767.php:13 | ||
Stack trace: | ||
#0 %sbug61767.php(13): {closure}(8, 'Undefined varia...', '%s', 13, Array) | ||
#1 {main} | ||
thrown in %sbug61767.php on line 13 | ||
|
||
Fatal error: Call to a member function foo() on a non-object in %sbug61767.php on line 13 | ||
Shutting down | ||
Array | ||
( | ||
[type] => 1 | ||
[message] => Call to a member function foo() on a non-object | ||
[file] => %sbug61767.php | ||
[line] => 13 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters