-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jaswsinc
committed
Jul 24, 2015
1 parent
b2f7f0e
commit 4ee609a
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2108,8 +2108,8 @@ public function remove_wp_cache_from_wp_config() | |
if(!preg_match('/([\'"])WP_CACHE\\1/i', $wp_config_file_contents)) | ||
return $wp_config_file_contents; // Already gone. | ||
|
||
if(preg_match('/define\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:0|FALSE|NULL|([\'"])0?\\2)\s*\)\s*;/i', $wp_config_file_contents)) | ||
return $wp_config_file_contents; // It's already disabled; no need to modify this file. | ||
if(preg_match('/define\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:0|FALSE|NULL|([\'"])0?\\2)\s*\)\s*;/i', $wp_config_file_contents) && !is_writable($wp_config_file)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
raamdev
Contributor
|
||
return $wp_config_file_contents; // It's already disabled, and since we can't write to this file let's let this slide. | ||
|
||
if(!($wp_config_file_contents = preg_replace('/define\s*\(\s*([\'"])WP_CACHE\\1\s*,\s*(?:\-?[0-9\.]+|TRUE|FALSE|NULL|([\'"])[^\'"]*\\2)\s*\)\s*;/i', '', $wp_config_file_contents))) | ||
return ''; // Failure; something went terribly wrong here. | ||
|
@raamdev I feel that the reason for multiple definitions in some rare cases, is because this
WP_CACHE
removal routine is returning true whenever it finds an existingFALSE
-like value. Instead, this routine should remove anyWP_CACHE
definition that it finds, even if the existing value isFALSE
-like.However, there is one exception. If the
wp-config.php
file isn't writable to begin with, we can't write to it, and thus, if we are trying to remove and it's already aFALSE
-like value that is not writable, then a removal routine can simply return true in that special case; i.e.,WP_CACHE
is already off :-)Therefore, by adding this
!is_writable()
check we continue past this point. Thereby avoiding the duplicate entry problem that we are trying to resolve. The duplicate entry being a result of this method being called upon to do it's job, and failing--right before we addWP_CACHE
in another method.