From 4ee609aa6fcb3a6a4b56a595978153b1c6d82db7 Mon Sep 17 00:00:00 2001 From: jaswsinc Date: Thu, 23 Jul 2015 23:36:03 -0800 Subject: [PATCH] Improve WP_CACHE removal. See: websharks/zencache#509 --- zencache/zencache.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zencache/zencache.inc.php b/zencache/zencache.inc.php index 6bfe079..46f233d 100644 --- a/zencache/zencache.inc.php +++ b/zencache/zencache.inc.php @@ -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)) + 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.