1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 20:27:31 +02:00

Fixed bug that restore_error_handler will not be executed if there is an exception before restore should happen (#1815)

This commit is contained in:
李铭昕
2023-06-22 14:44:58 +08:00
committed by GitHub
parent 426e42795c
commit 1b93764d15

View File

@@ -135,11 +135,14 @@ class StreamHandler extends AbstractProcessingHandler
$this->createDir($url); $this->createDir($url);
$this->errorMessage = null; $this->errorMessage = null;
set_error_handler([$this, 'customErrorHandler']); set_error_handler([$this, 'customErrorHandler']);
try {
$stream = fopen($url, 'a'); $stream = fopen($url, 'a');
if ($this->filePermission !== null) { if ($this->filePermission !== null) {
@chmod($url, $this->filePermission); @chmod($url, $this->filePermission);
} }
} finally {
restore_error_handler(); restore_error_handler();
}
if (!is_resource($stream)) { if (!is_resource($stream)) {
$this->stream = null; $this->stream = null;