-
Notifications
You must be signed in to change notification settings - Fork 697
Closed
Labels
Description
Describe the bug
When FileLoggingHandler first tries to create the log file, it necessarily fails since symfony/filesystem's touch method returns void, whereas FileLoggingHandler uses it as though it returns boolean.
See:
$file = new File($this->logFile, false);
// Suppress E_WARNING if not exists
if (@$this->fileSystem->exists($this->logFile)) {
if (!$file->isWritable()) {
throw new CannotWriteFileException(
sprintf("Could not write to logfile: %s", $this->logFile),
);
}
// this is necessarily true, since `touch` returns void. `touch` throws an exception on failure.
} elseif (!$this->fileSystem->touch($this->logFile)) {
throw new CannotWriteFileException(sprintf(
"The logging directory is not writable for the web server user. Could not create logfile: %s",
$this->logFile,
));
}To Reproduce
- Turn on filesystem logging in the configuration
- pointing the logger at a file that doesn't yet exist
- prompt it to log something, note it creates the log file, but then immediately throws an exception
- subsequent attempts will succeed, since the file will exist
Expected behavior
it should not fail by default if the log file doesn't yet exist.
Screenshots or logs
n/a
Additional context
I believe simplesamlphp used to use PHP's touch method previously, which does have a boolean return indicating success.