Handle low diskspace errors

* First commit fixes #2542 which occurs on PHP < 5.4.0 when the temporary directory is full
* Second commit displays a warning if cache write fails due to low disk space