Skip to content

Commit

Permalink
Fixed bug that restore_error_handler will not be executed if there …
Browse files Browse the repository at this point in the history
…is an exception before restore should happen (#1815)
  • Loading branch information
limingxinleo authored Jun 22, 2023
1 parent 426e427 commit 1b93764
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Monolog/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,14 @@ protected function write(array $record): void
$this->createDir($url);
$this->errorMessage = null;
set_error_handler([$this, 'customErrorHandler']);
$stream = fopen($url, 'a');
if ($this->filePermission !== null) {
@chmod($url, $this->filePermission);
try {
$stream = fopen($url, 'a');
if ($this->filePermission !== null) {
@chmod($url, $this->filePermission);
}
} finally {
restore_error_handler();
}
restore_error_handler();
if (!is_resource($stream)) {
$this->stream = null;

Expand Down

0 comments on commit 1b93764

Please sign in to comment.