wp-cli / wp-super-cache-cli

A CLI interface for the WP Super Cache plugin
http://wordpress.org/support/topic/patch-for-wp-cli-command-1
58 stars 17 forks source link

Should super-cache enable / disable modify $cache_enabled? #17

Open playmono opened 6 years ago

playmono commented 6 years ago

Hi all,

I did some tests using this package on my wordpress installations and because I don't know much how works wordpress cache, I was wondering some questions.

As I can see, if run this

$ wp --path='/var/www/wordpress' super-cache enable

The only thing that changes is in wp-cache-config.php - $super_cache_enabled = 'true';

But in wordpress frontend, cache still remains disabled:

image

The same thing happens with

$ wp --path='/var/www/wordpress' super-cache disable

variable$super_cache_enabled changes to false but in frontend, cache remains enabled.

So, I did some research and I see that in frontend if you enable or disable cache, two variables of wp-cache-config.php changes: $cache_enabled and $super_cache_enabled

My workaround to solve this was in enable / disable functions of super-cache package adding wp_cache_disable(); and wp_cache_enable();.

super-cache.txt

But my concern is if maybe super-cache enable / disable should affect only to super-cache plugin (as it is now). In the other side, in wordpress frontend, if you check / uncheck enabling cache, you are modifying the two values.

What do you think guys?

Thank you.

playmono commented 6 years ago

Ok #16 resolves all.

schlessera commented 6 years ago

This is still an issue, as #16 was never merged.

schlessera commented 6 years ago

Especially with the new super-cache status planned in #24 , this is very misleading: image 2018-10-26 at 11 59 43 am

stodorovic commented 6 years ago

I'm working on this issue. We should better handle errors because enabling caching should modify .htaccess to update rewrite rules (if Expert method - mod_rewrite is selected). I hope that I'll create new PR soon.

schlessera commented 6 years ago

In this case, there's already a discrepancy between what super-cache enable checks to determine success ($super_cache_enabled) and what super-cache status checks to determine state ($cache_enabled && $super_cache_enabled).

Checking errors is of course important, but checking the result consistently is probably an easy first step.

stodorovic commented 6 years ago

I just made quick fix - PR #25. We need to check only $cache_enabled because commands should disable/enable both methods. I just tested add_mod_rewrite_rules() and it seems that works correctly. Anyway there isn't command for changing "Cache Delivery Method" and it's safe because Expert mode (fist time) can be selected only from WPSC dashboard.

I'll try to review preload command and then I'll try to make better error checking.

@playmono Could you test these changes?