failed to open stream: No such file or directory
-
My php error_log file is filled with lines like the following…
fopen(D://wordpress/wp-content/plugins/bwp-minify/cache/minify_g1screen,galleria.classic,magnificpopup,style.css_02f55215feb10228e5d801cea9a9de48.gz): failed to open stream: No such file or directory in D:\wordpress\wp-content\plugins\bwp-minify\min\lib\Minify\Cache\File.php on line 100
flock() expects parameter 1 to be resource, boolean given in D:\wordpress\wp-content\plugins\bwp-minify\min\lib\Minify\Cache\File.php on line 101
stream_get_contents() expects parameter 1 to be resource, boolean given in D:\wordpress\wp-content\plugins\bwp-minify\min\lib\Minify\Cache\File.php on line 102
flock() expects parameter 1 to be resource, boolean given in D:\wordpress\wp-content\plugins\bwp-minify\min\lib\Minify\Cache\File.php on line 103
fclose() expects parameter 1 to be resource, boolean given in D:\wordpress\wp-content\plugins\bwp-minify\min\lib\Minify\Cache\File.php on line 104The files it is looking for do not exist in that path or any other, however, similarly named files do appear in that path.
My solution thus far has been to alter the function to test for the existence of the file before trying to open, lock or close the file. If the file doesn’t exist, I return nothing. This cleaned up me error_log and the site seems to be functioning fine otherwise.
Is there a problem with my solution, or a better one?
If not, maybe you want to add this change to future updates? Code is below.
/** * Fetch the cached content * * @param string $id cache id (e.g. a filename) * * @return string */ public function fetch($id) { if (file_exists($this->_path . '/' . $id)) { if ($this->_locking) { $fp = fopen($this->_path . '/' . $id, 'rb'); flock($fp, LOCK_SH); $ret = stream_get_contents($fp); flock($fp, LOCK_UN); fclose($fp); return $ret; } else { return file_get_contents($this->_path . '/' . $id); } } else { return; } }
- The topic ‘failed to open stream: No such file or directory’ is closed to new replies.