Skip to content
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

Multiple WP_CACHE definitions in wp-config.php #509

Closed
eurobank opened this issue Jun 19, 2015 · 7 comments
Closed

Multiple WP_CACHE definitions in wp-config.php #509

eurobank opened this issue Jun 19, 2015 · 7 comments
Assignees

Comments

@eurobank
Copy link

Removing my old caching plugin, a

define('WP_CACHE', FALSE);

was left in wp-config.php. ZenCache added

define('WP_CACHE', TRUE);

at the top but didn't removed the FALSE, so i have two of this in my config. And apparently the FALSE is active (not sure).

Thanks

@raamdev
Copy link
Contributor

raamdev commented Jun 19, 2015

@eurobank Thank you for the report! I have confirmed this bug.

When wp-config.php already contains a WP_CACHE definition, ZenCache is not properly removing/updating the existing value.

I have noticed that several other caching plugins, such as WP Super Cache, do not clean up after themselves when they are deactivated and deleted. They will leave behind the WP_CACHE definition inside wp-config.php instead of cleaning it up as they should (as ZenCache does when it is uninstalled).

@raamdev raamdev changed the title Two "define WP_CACHE" Multiple WP_CACHE definitions in wp-config.php Jun 19, 2015
@jaswrks
Copy link

jaswrks commented Jun 20, 2015

@raamdev writes...

When wp-config.php already contains a WP_CACHE definition, ZenCache is not properly removing/updating the existing value.

That's definitely a bug, because this should happen; i.e., the intention is that we remove it before we add it back in, and fail if that is not possible.

Referencing: https://github.com/websharks/zencache/blob/150605-RC/src/includes/closures/Plugin/InstallUtils.php#L132

If you see this again, try to grab the raw file contents from the /wp-config.php file so we can analyze further, because there must be something slightly different about it for ZenCache not to pick it up; i.e., our regex pattern might need improvement.

@raamdev
Copy link
Contributor

raamdev commented Jun 20, 2015

@jaswsinc Here you go:

<?php
define('WP_CACHE', TRUE);
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, and ABSPATH. You can find more information by visiting
 * {@link http://codex.wordpress.org/Editing_wp-config.php Editing wp-config.php}
 * Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('WP_CACHE', false); //Added by WP-Cache Manager
define( 'WPCACHEHOME', '/Users/raam/Sites/zcpro.dev/wordpress/wp-content/plugins/wp-super-cache/' ); //Added by WP-Cache Manager
define('DB_NAME', 'zcdevpro');

Maybe it's the //Added by WP-Cache Manager on the same line that's messing up the regex? Or false being lowercase?

@jaswrks
Copy link

jaswrks commented Jun 21, 2015

Thanks! :-)

So I verified the problem is not:

  • A caSe problem with false.
  • A problem with the //Added by WP-Cache Manager comment.
  • A problem with the regex pattern itself.

It seems this bug is a bigger problem than I thought. It is related to this line:
https://github.com/websharks/zencache/blob/150605-RC/src/includes/closures/Plugin/InstallUtils.php#L174

The assumption is that an existing FALSE value for WP_CACHE is acceptable, because this method was originally written to disable WP_CACHE instead of removing it entirely; i.e., if an existing define('WP_CACHE', FALSE) is found, that's OK as far as this method is concerned, because it is disabled when that's the case.

However, it's NOT OK if we do in fact want to strip away all existing values for WP_CACHE before adding a new one. That's what addWpCacheToWpConfig() needs whenever it calls removeWpCacheFromWpConfig() before adding it back in.

I just looked through the rest of the codebase, and that's what all calls to this method want now too, so far as I can see. So I think the logic used by this method needs to change in order to resolve this.

Possible Resolution

  • Remove these lines from the removeWpCacheFromWpConfig() method.

@eurobank
Copy link
Author

This may sound naive but why remove the FALSE and not just change it to TRUE, not even changing the place in wp-config.php ...

@raamdev raamdev modified the milestones: Next Release (Pro), Future Release Jul 10, 2015
@jaswrks jaswrks self-assigned this Jul 24, 2015
jaswrks pushed a commit to wpsharks/comet-cache-pro that referenced this issue Jul 24, 2015
jaswrks pushed a commit that referenced this issue Jul 24, 2015
@raamdev
Copy link
Contributor

raamdev commented Jul 27, 2015

Next Lite Release changelog:

  • Bug Fix: Fixed a bug where, in some rare cases, wp-config.php would end up with two WP_CACHE definitions. See Issue #509.

@raamdev
Copy link
Contributor

raamdev commented Jul 27, 2015

Next Pro Release changelog:

  • Bug Fix: Fixed a bug where, in some rare cases, wp-config.php would end up with two WP_CACHE definitions. See Issue #509.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants