Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.59k stars 798 forks source link

v1.5.4+ no longer support read-only wp-cache-config.php #25529

Open oxyc opened 7 years ago

oxyc commented 7 years ago

In https://github.com/Automattic/wp-super-cache/commit/3dd7420dc37ee37b27a029b5be16e6abe345b45e the possibility to have wp-cache-config.php read-only broke due to constant writes without checking permissions first.

This can be reproduced by removing write access to the wp-cache-config.php file and triggering GC by saving a post. It causes a white screen with the permission problem mentioned.

donnchawp commented 7 years ago

Did you get a PHP fatal error? This is a permission check in the wp_cache_replace_line() function that updates the config file. Currently a warning is displayed to the browser but in 1.5.6 (which will be released soon) that warning is changed to a trigger_error().

Can you grab the code from here (master) and give it a spin? It will unfortunately send error messages to your PHP error log but no text should be sent to the browser.

oxyc commented 7 years ago

Ah great, thanks for the quick response. No it was not a fatal error, just the message which will be fixed then.

I'll still unhook that action on our sites so it doesn't write to the error log on every gc run.

oxyc commented 7 years ago

I can close this if you consider the error log messages to be working as intended.

donnchawp commented 7 years ago

No, leave this open. A better way to handle the issue is to report an error at a set rate rather than all the time to avoid clogging up the log files.

Or even not report an error at all if the plugin was in some sort of "read only" mode.

oxyc commented 7 years ago

Hiding the error when in "read only" mode sounds great. I think it's a valid use case to not allow the webserver write access to PHP files. Coming from a Drupal background that was an obvious decision on my part and I bet it's common for others to make that same decision too.