Skip to content

Commit

Permalink
Prefer classic if construct #20294
Browse files Browse the repository at this point in the history
  • Loading branch information
xcopy committed Dec 9, 2024
1 parent b3c23da commit 52ff9db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions framework/caching/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ protected function setValue($key, $value, $duration)
}

$message = "Unable to write cache file '{$cacheFile}'";

Check warning on line 161 in framework/caching/FileCache.php

View check run for this annotation

Codecov / codecov/patch

framework/caching/FileCache.php#L161

Added line #L161 was not covered by tests
($error = error_get_last()) and $message .= ": {$error['message']}";

if ($error = error_get_last()) {
$message .= ": {$error['message']}";

Check warning on line 164 in framework/caching/FileCache.php

View check run for this annotation

Codecov / codecov/patch

framework/caching/FileCache.php#L163-L164

Added lines #L163 - L164 were not covered by tests
}

Yii::warning($message, __METHOD__);

Check warning on line 167 in framework/caching/FileCache.php

View check run for this annotation

Codecov / codecov/patch

framework/caching/FileCache.php#L167

Added line #L167 was not covered by tests

Expand Down Expand Up @@ -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()) {

Check warning on line 280 in framework/caching/FileCache.php

View check run for this annotation

Codecov / codecov/patch

framework/caching/FileCache.php#L279-L280

Added lines #L279 - L280 were not covered by tests
$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']}";

Check warning on line 289 in framework/caching/FileCache.php

View check run for this annotation

Codecov / codecov/patch

framework/caching/FileCache.php#L287-L289

Added lines #L287 - L289 were not covered by tests
}
}
}
$message and Yii::warning($message, __METHOD__);
Expand Down
4 changes: 3 additions & 1 deletion framework/log/FileTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']}";

Check warning on line 136 in framework/log/FileTarget.php

View check run for this annotation

Codecov / codecov/patch

framework/log/FileTarget.php#L134-L136

Added lines #L134 - L136 were not covered by tests
}
throw new LogRuntimeException($message);

Check warning on line 138 in framework/log/FileTarget.php

View check run for this annotation

Codecov / codecov/patch

framework/log/FileTarget.php#L138

Added line #L138 was not covered by tests
}
$textSize = strlen($text);
Expand Down

0 comments on commit 52ff9db

Please sign in to comment.