-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Commented out WP_CACHE definition in wp-config.php being incorrectly ignored #591
Comments
@davidfavor Thanks for the report. This should have been addressed in v150821 (ZenCache Pro) and v150930 (ZenCache Lite). See #509 I'm going to run a few tests to see if I can reproduce this issue. Can you tell me which version of ZenCache you are running? |
I have confirmed this bug following @davidfavor's steps above with both ZenCache Lite v150930 and ZenCache Pro (dev branch). If the
@jaswsinc It looks like this regex is not taking into consideration that |
The above comment only referenced the ZenCache Pro codebase. Noting here that this should also be fixed in ZenCache Lite (via this line). |
Good catch guys! I agree, there is room for improvement here. @raamdev You could try playing with a negative lookbehind in that line you referenced. i.e., if (preg_match('/(?<!\/\/\s*)define\s*\(\s*([\'"])WP_CACHE ...
Looks like there is at least one instance of this in the removal routine also that needs to be updated. |
@jaswsinc Thanks! I started playing with negative lookbehinds but
https://regex101.com/r/aA0yT1/2
Which throws a wrench into the mix. It seems like we can check for one particular scenario ( |
Nice! I see what you mean. Well, I think it's fine to pull the
|
Ah. Nevermind. Tricky! That doesn't work either. |
Yep, I tried that too! |
Why don't we just remove |
In other words, just remove this entire conditional and just let the next line ( |
That's a decent idea. However, the reason it's like that right now, is to cover a scenario where the Here is a modified version of the regex that seems to work. If you can take a closer look I'd appreciate it. See: https://regex101.com/r/fD4wK5/2
Instead of doing a lookbehind, we can be more specific about what we want to find. The |
Or, this might be even better. We could strip all comments from the syntax before we check. See: http://php.net/manual/en/function.php-strip-whitespace.php |
Ah, that makes sense. Yeah, that's an important scenario to consider.
Yep, that seems to work. I ran it through a few tests (including directly in ZenCache) and it's working as expected.
Hmm, that would work too. Any preference? |
My preference would be to strip the comments before we do a check. That seems bulletproof in terms of us being able to accurately detect whether it's really in there or not. You could then leave the regex as-is. However, while you're in there it's probably a good idea to change: this:
to:
That avoids a false match on something wild like: |
Next Pro Release Changelog:
|
Next Lite Release Changelog:
|
Thanks for fixing this so fast! BTW, the only reason I figured this bug out instantly is I've done the same thing in my code several times. |
@davidfavor Ha! Always better to have more eyes on the bugs. 🐛 🪲 Thanks again. 😄 |
ZenCache v151114 has been released and includes changes from this GitHub Issue. See the v151114 announcement for further details. This issue will now be locked to further updates. If you have something to add related to this GitHub Issue, please open a new GitHub Issue and reference this one (#591). |
:::: Summary
This relates specifically when moving from WP Super Cache to ZenCache. Likely also effects other caching plugins besides WP Super Cache.
A slight code modification should fix this problem. See details below.
The bottom line is this bug prohibits ZenCache from ever really being enabled, as WP_CACHE remains commented out.
This means ZenCache appears to be slow, as it's code never really executes.
:::: Detailed Explanation
ZenCache appears to sometimes missing updating wp-config.php with the WP_CACHE directive.
Here's how to reproduce this on WP-4.3.1 with all updates installed.
Starting point is clean wp-config.php - no caching plugins installed + no wp-config.php directives. Site speed is 45 reqs/sec
Install + Activate WP Super Cache. Site speed increases to 2500 reqs/sec with wp-config.php of...
define('WP_CACHE', true); //Added by WP-Cache Manager
define( 'WPCACHEHOME', '/sites/drf/fastseohosting.com/wordpress/wp-content/plugins/wp-super-cache/' ); //Added by WP-Cache Manager
Deactivate WP Super Cache + wp-config.php changes to...
//define('WP_CACHE', true); //Added by WP-Cache Manager
define( 'WPCACHEHOME', '/sites/drf/fastseohosting.com/wordpress/wp-content/plugins/wp-super-cache/' ); //Added by WP-Cache Manager
Install + Activate ZenCache + wp-config.php no changes (as expected)
In ZenCache settings enable + save config + wp-config.php does not change.
//define('WP_CACHE', true); //Added by WP-Cache Manager
WP_CACHE still appears to be commented out.
:::: Suggested Fix
In zencache.inc.php it appears tests for WP_CACHE require being anchored to left, rather than unanchored (floating).
Test likely should be - ^define... - rather than - define... - which will match the commented out define cruft left over from WP Super Cache.
The text was updated successfully, but these errors were encountered: