From 52ff9dbd485a5fbe370d5b29ae0a1d4ca7700a6b Mon Sep 17 00:00:00 2001 From: Kairat Jenishev Date: Mon, 9 Dec 2024 17:59:51 +0600 Subject: [PATCH] Prefer classic `if` construct #20294 --- framework/caching/FileCache.php | 13 ++++++++++--- framework/log/FileTarget.php | 4 +++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/framework/caching/FileCache.php b/framework/caching/FileCache.php index bdca7789b1b..864299f840f 100644 --- a/framework/caching/FileCache.php +++ b/framework/caching/FileCache.php @@ -159,7 +159,10 @@ protected function setValue($key, $value, $duration) } $message = "Unable to write cache file '{$cacheFile}'"; - ($error = error_get_last()) and $message .= ": {$error['message']}"; + + if ($error = error_get_last()) { + $message .= ": {$error['message']}"; + } Yii::warning($message, __METHOD__); @@ -274,13 +277,17 @@ protected function gcRecursive($path, $expiredOnly) if (!$expiredOnly) { if (!@rmdir($fullPath)) { $message = "Unable to remove directory '$fullPath'"; - ($error = error_get_last()) and $message .= ": {$error['message']}"; + if ($error = error_get_last()) { + $message .= ": {$error['message']}"; + } } } } elseif (!$expiredOnly || $expiredOnly && @filemtime($fullPath) < time()) { if (!@unlink($fullPath)) { $message = "Unable to remove file '$fullPath'"; - ($error = error_get_last()) and $message .= ": {$error['message']}"; + if ($error = error_get_last()) { + $message .= ": {$error['message']}"; + } } } $message and Yii::warning($message, __METHOD__); diff --git a/framework/log/FileTarget.php b/framework/log/FileTarget.php index b68da965622..d860c4014ef 100644 --- a/framework/log/FileTarget.php +++ b/framework/log/FileTarget.php @@ -132,7 +132,9 @@ public function export() $writeResult = @fwrite($fp, $text); if ($writeResult === false) { $message = "Unable to export log through file ($this->logFile)!"; - ($error = error_get_last()) and $message .= ": {$error['message']}"; + if ($error = error_get_last()) { + $message .= ": {$error['message']}"; + } throw new LogRuntimeException($message); } $textSize = strlen($text);