From af8efac0d58e524aead247ce64445a66e6d7c553 Mon Sep 17 00:00:00 2001 From: Max Ageev Date: Thu, 9 Jun 2022 14:23:32 +0300 Subject: [PATCH] Check if errorMessage contain error "File exists" Fixes #1678, closes #1685 When we try to create directory we got error and find out that error is to the fact that directory already was created for us. If that the case we should not throw exception as it's fine now... If file was deleted after that it's not problem of this funtion. --- src/Monolog/Handler/StreamHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Monolog/Handler/StreamHandler.php b/src/Monolog/Handler/StreamHandler.php index e6c79569..3550c8c1 100644 --- a/src/Monolog/Handler/StreamHandler.php +++ b/src/Monolog/Handler/StreamHandler.php @@ -212,7 +212,7 @@ class StreamHandler extends AbstractProcessingHandler set_error_handler([$this, 'customErrorHandler']); $status = mkdir($dir, 0777, true); restore_error_handler(); - if (false === $status && !is_dir($dir)) { + if (false === $status && !is_dir($dir) && strpos($this->errorMessage, 'File exists') !== false) { throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and it could not be created: '.$this->errorMessage, $dir)); } }