From 9825c136d9efb8f0b399fb8f3838c7a62ac93e17 Mon Sep 17 00:00:00 2001 From: dyszczo <krzysztof.dyszczyk@gmail.com> Date: Thu, 23 Jul 2020 14:18:39 +0200 Subject: [PATCH] fix(notice): fatal when trying to write into unwritable --- src/WP/WPCapture.php | 6 +++++- src/WPDeskLoggerFactory.php | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/WP/WPCapture.php b/src/WP/WPCapture.php index f0c1789..ddc9155 100644 --- a/src/WP/WPCapture.php +++ b/src/WP/WPCapture.php @@ -87,7 +87,11 @@ class WPCapture { } } - return true; + if (!is_writable($log_file)) { + $this->add_notice_for_file($log_file); + return false; + } + return true; } /** diff --git a/src/WPDeskLoggerFactory.php b/src/WPDeskLoggerFactory.php index d573465..6b39b9c 100644 --- a/src/WPDeskLoggerFactory.php +++ b/src/WPDeskLoggerFactory.php @@ -114,7 +114,9 @@ class WPDeskLoggerFactory extends BasicLoggerFactory */ private function appendMainLog($logger) { $wpCapture = $this->captureWPLog(); - $this->appendFileLog($logger, $wpCapture->get_log_file()); + if (is_writable($wpCapture->get_log_file())) { + $this->appendFileLog($logger, $wpCapture->get_log_file()); + } } /** -- GitLab