Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot write empty configuration #4

Closed
tiborb opened this issue Mar 30, 2015 · 0 comments
Closed

Cannot write empty configuration #4

tiborb opened this issue Mar 30, 2015 · 0 comments

Comments

@tiborb
Copy link

tiborb commented Mar 30, 2015

When I attempt to write an empty config to a file (say, I removed the last remaining section) using Supervisor\Configuration\Writer\File it will throw a [Supervisor\Exception\WrittingFailed] Cannot write configuration into file /path/to/file.conf exception.

Storing an empty string to a file $this->writeFile($fileContents)) will return 0, this in turen gets evaluates as false, and an exception will be thrown:

if (!$result = $this->writeFile($fileContents)) {
            throw new WrittingFailed(sprintf('Cannot write configuration into file %s', $this->file));
        }

Even though the write operation was successful.
Non boolean value go evaluated to false, a check for boolean false fixes this issue:

if (false === $result = $this->writeFile($fileContents)) {
            throw new WrittingFailed(sprintf('Cannot write configuration into file %s', $this->file));
        }

More details: http://php.net/manual/en/function.file-put-contents.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant