keycdn / cache-enabler

A lightweight caching plugin for WordPress that makes your website faster by generating static HTML files.
https://wordpress.org/plugins/cache-enabler/
123 stars 46 forks source link

WP_CACHE Bug #145

Closed tobias992 closed 3 years ago

tobias992 commented 3 years ago

Hello, today i tested the 1.5.0 "beta" and found one bug.

The - define( 'WP_CACHE', true ); - is not set correctly in wp-config.php I tested with no entry also with - define( 'WP_CACHE', false ); - but without success. I had to set this manual in wp-config.php and then all was working fine.

coreykn commented 3 years ago

We've made it more strict on when we make changes to the wp-config.php file. We won't set this automatically if the WP_CACHE constant is found (PR #102). We also won't set it if the config file is not what we would consider to be the default config file (PR #140). Currently this is done by looking for /** Sets up WordPress vars and included files. */. This is our attempt to make a cleaner addition, prevent changes to heavily modified config files, and is the lowest location WP_CACHE constant can be set (as it needs to occur before WordPress sets up its vars and included files). Does your wp-config.php file contain this?

tobias992 commented 3 years ago

Hi, its a clean generated wp-config.php with WP-CLI. I dont understand why there are these Problems now. Every Caching Plugin set the - define( 'WP_CACHE', true ); - value or modify from "false" to "true".

Why not Cache Enabler.

tobias992 commented 3 years ago

For example we can use WP-Rocket. This plugin dont remove the - define( 'WP_CACHE', true ); - value after plugin remove. They only switch from "true" to "false". So its not possible to easy use Cache Enabler after WP-Rocket. A user have to modify the wp-config.php wich is not very user friendly.

coreykn commented 3 years ago

Please provide the exact steps to replicate this issue.

Cache Enabler won't automatically overwrite the wp-config.php file in certain conditions. Detailed reasoning for why this was changed was provided in the aforementioned PRs. On my list of todos is introducing a simple way to add or overwrite the wp-config.php file when we did not set the WP_CACHE constant. This would be a link in the WP_CACHE notice in the Cache Enabler settings.

tobias992 commented 3 years ago

The Steps are very easy.

  1. Install WP-Rocket
  2. Remove WP-Rocket
  3. Install Cache Enabler
  4. At Cache Enabler Page in Backend i get the "define( 'WP_CACHE', true ); missing" warning.
coreykn commented 3 years ago

This has all been explained then. This is not a bug and is working exactly as expected. Cache Enabler won't make changes to the wp-config.php file automatically if we detect the WP_CACHE constant (regardless of how it's been defined). We'll likely add a way to manually force this. That way the user can decide whether or not Cache Enabler overwrites an already defined constant.

I think a plugin should never leave any code that it has added once it has been deactivated and/or uninstalled, which is what I've ensured Cache Enabler does.

tobias992 commented 3 years ago

For you and me there is no problem to add these. But for the "normal" user thats is a bad way for Cache Enabler. Cache Enabler stay for simplicity... install, activate and finish. Looks like this time is over now... what a shame.

coreykn commented 3 years ago

@tobias992 I don't believe you have all of the context. That is how it works in nearly all cases. You've pointed out one edge case and are applying it to all cases.

Nearly all systems require explicit instruction for an overwrite to proceed as that decision should be on the user. If you've read the PRs you would have all the information you need about why this was changed. If you have questions or concerns just let me know, but please keep in mind that I need constructive feedback in place of complaints. As I've mentioned twice now I already have a solution planned for the edge cases like you've experienced, which would just be a simple link in the warning that can be clicked to force the overwrite.