From f69670fb65610488fb5c1a624896d12565464bc4 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 17 Feb 2020 15:53:03 +0300 Subject: [PATCH] Fix #17798: Avoid creating folder for stream log targets in `FileTarget` --- framework/CHANGELOG.md | 1 + framework/log/FileTarget.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e9ccf24..4c530d7 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.33 under development ------------------------ +- Bug #17798: Avoid creating folder for stream log targets in `FileTarget` (wapmorgan) - Bug #17850: Update to `ReplaceArrayValue` config exception message (alex-code) - Bug #17843: Fix `yii\web\Session::setCookieParamsInternal` check param "samesite" (schevgeny) - Bug #17828: Fix `yii\web\UploadedFile::saveAs()` failing when error value in `$_FILES` entry is a string (haveyaseen) diff --git a/framework/log/FileTarget.php b/framework/log/FileTarget.php index d0b598d..1a9ad1e 100644 --- a/framework/log/FileTarget.php +++ b/framework/log/FileTarget.php @@ -101,8 +101,10 @@ class FileTarget extends Target */ public function export() { - $logPath = dirname($this->logFile); - FileHelper::createDirectory($logPath, $this->dirMode, true); + if (strpos($this->logFile, '://') === false || strncmp($this->logFile, 'file://', 7) === 0) { + $logPath = dirname($this->logFile); + FileHelper::createDirectory($logPath, $this->dirMode, true); + } $text = implode("\n", array_map([$this, 'formatMessage'], $this->messages)) . "\n"; if (($fp = @fopen($this->logFile, 'a')) === false) {