Fix #18120: Include path to the log file into error message if FileTarget::export fails

This commit is contained in:
Oleg Poludnenko
2020-06-19 11:35:14 +03:00
committed by GitHub
parent a41879a321
commit 658c822f30
2 changed files with 5 additions and 4 deletions

View File

@ -19,6 +19,7 @@ Yii Framework 2 Change Log
- Enh #18083: Add `Controller::$request` and `$response` (brandonkelly)
- Bug #18101: Fix behavior of OUTPUT INSERTED.* for SQL Server query: "insert default values"; correct MSSQL unit tests; turn off profiling echo message in migration test (darkdef)
- Bug #18105: Fix for old trigger in RBAC migration with/without prefixTable (darkdef)
- Enh #18120: Include path to the log file into error message if `FileTarget::export` fails (uaoleg)
2.0.35 May 02, 2020

View File

@ -123,21 +123,21 @@ class FileTarget extends Target
$writeResult = @file_put_contents($this->logFile, $text, FILE_APPEND | LOCK_EX);
if ($writeResult === false) {
$error = error_get_last();
throw new LogRuntimeException("Unable to export log through file!: {$error['message']}");
throw new LogRuntimeException("Unable to export log through file ({$this->logFile})!: {$error['message']}");
}
$textSize = strlen($text);
if ($writeResult < $textSize) {
throw new LogRuntimeException("Unable to export whole log through file! Wrote $writeResult out of $textSize bytes.");
throw new LogRuntimeException("Unable to export whole log through file ({$this->logFile})! Wrote $writeResult out of $textSize bytes.");
}
} else {
$writeResult = @fwrite($fp, $text);
if ($writeResult === false) {
$error = error_get_last();
throw new LogRuntimeException("Unable to export log through file!: {$error['message']}");
throw new LogRuntimeException("Unable to export log through file ({$this->logFile})!: {$error['message']}");
}
$textSize = strlen($text);
if ($writeResult < $textSize) {
throw new LogRuntimeException("Unable to export whole log through file! Wrote $writeResult out of $textSize bytes.");
throw new LogRuntimeException("Unable to export whole log through file ({$this->logFile})! Wrote $writeResult out of $textSize bytes.");
}
@flock($fp, LOCK_UN);
@fclose($fp);