This is such a dumb error but I wanted to write it in case anybody else becomes mystified if a stable PHP application starts suddenly behaving erratically when writing to files.
The cause of this weird behavior could be that your server’s hard drive has run out of free space. To check your server’s drive space on a Unix machine, you use the “df” command. This will show you a percentage of used space. If it’s in the high 90′s then obviously you need to clean out some files or upgrade the hardware.
This can cause a wide variety of very strange symptoms including:
- Permission denied errors are thrown when opening, writing or closing files even though PHP has full permission granted
- PHP stops appending to log files
- PHP can create new files, but they are empty even though you are expecting PHP to write some data)
- PHP can’t start new sessions, or doesn’t remember user’s session (because it can’t write session files)
- Unknown error in Line 0. (This actually occurs if you have an exception in your destructor, however this is a common place to close file handles so you might see this error)
Obviously the server is in an unreliable state so it’s likely to cause all kinds of weird and seemingly random behavior. If you notice any other symptoms feel free to post a comment.