Closed janvitos closed 4 years ago
I will be adding a simple fix to the code.
Replacing line 408:
} else {
With:
} else if ( file_exists( $object ) ) {
Seems to do the trick.
Improving the cache size is on my list of todos as there are limitations with how it's currently handled. I'm unable to replicate this specific issue so I'd like to troubleshoot it a little further to understand what is occurring.
Is this an issue you're able to provide steps to replicate or a rare edge case that you noticed? Currently only files that exist will be found when the data of a directory is being retrieved, which is why I'm curious what file that was found is causing this warning to be thrown.
Sorry for the delay.
I will do more testing and get back to you soon with steps and result.
Hi @coreykn,
So I removed the code I modified and did a bit more testing.
The problem actually happens when calling do_action( 'ce_clear_cache' ). I added a button in my theme to manually clear the cache using that action.
To reproduce the problem, this is what I do:
2020/09/22 22:10:51 [error] 704431#704431: *1250969 FastCGI sent in stderr: "PHP message: PHP Warning: filesize(): stat failed for /home/xxxx/xxxx/wordpress/wp-content/cache/cache-enabler/www.xxxx.com/avoir-lapin-paques-mauvaise-idee-mshissypants in /home/xxxx/xxxx/wordpress/wp-content/plugins/cache-enabler/inc/cache_enabler_disk.class.php on line 409PHP
When I add my fix, the errors completely disappear from the NGINX error log.
I believe filesize() is being called on non existing directories and that's why it throws the stat failed warning. I'm thinking maybe some directories are deleted before filesize() is called.
Ok, I think I know what's going on.
The problem happens only when clicking my custom Purge Cache button that calls do_action('ce_clear_cache') from the Wordpress Dashboard.
I believe what is happening is that after clicking my Cache Purge button, do_action('ce_clear_cache') is called, directories start getting deleted, the Dashboard refreshes and triggers the dashboard_glance_items filter. The plugin then tries to calculate the cache size while the directories are still being deleted, so filesize() is being called on those deleted directories.
Without digging too much into the logic of the fix, I think my solution works and is easy to implement.
I did notice that the displayed Cache Size is not updated after a Cache Purge, but it gets updated on subsequent refreshes of the Dashboard.
Hi @coreykn,
I just saw that you just applied a big commit to another fork of Cache Enabler and that you tagged me about this issue.
Should this problem be resolved now? If so, I will be happy to install the new version and test it out.
Thanks.
Thanks for all of the feedback you've provided on this issue. Once the PR is merged this issue will be closed automatically. This issue should be resolved, however, I would love to have you test out the changes that I've made for a confirmation on your end. The more people that I can get testing the changes the better.
You can find these directly on my branch (coreykn/cache-enabler/tree/add-cache-engine) or wait for them to be merged with the master. (You may need to uninstall first if you happened to download any version of the master branch after 1.4.9 was released.)
That sounds great @coreykn.
I will test the new version and let you know how it goes.
Cheers.
Hi @coreykn, I just installed 1.5.1 and everything works great. This bug does not occur anymore.
Also, it is really nice that you added the clear cache on post save / update. I had added this function myself, but now I was able to remove my custom code since the plugin does it automatically now.
Great work.
Hi,
I noticed there are a bunch of warnings in my server's error log coming from Cache Enabler.
Here is the full warning message:
After doing a bit of investigation, I noticed Cache Enabler does NOT check for the existence of the file before calling the filesize() function. So when a file has been deleted and doesn't exist, it throws that warning message.