Version Description
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 1.6.6 |
Comparing to | |
See all releases |
Code changes from version 1.6.5 to 1.6.6
- readme.txt +8 -3
- wp-cache-phase2.php +5 -5
- wp-cache.php +80 -17
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
-
* Tested up to: 5.
|
5 |
-
* Stable tag: 1.6.
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
@@ -266,6 +266,11 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
266 |
|
267 |
## Changelog ##
|
268 |
|
|
|
|
|
|
|
|
|
|
|
269 |
### 1.6.5 ###
|
270 |
* Check advanced-cache.php was created by the plugin before modifying/deleting it. (#666)
|
271 |
* When saving settings, save blank lines. Fixes problems with WP_CACHE and WPCACHEHOME in wp-config.php. Related to #652. (#667)
|
@@ -713,4 +718,4 @@ Your theme is probably responsive which means it resizes the page to suit whatev
|
|
713 |
|
714 |
|
715 |
## Upgrade Notice ##
|
716 |
-
|
1 |
# WP Super Cache #
|
2 |
* Contributors: donncha, automattic, kraftbj
|
3 |
* Tags: performance, caching, wp-cache, wp-super-cache, cache
|
4 |
+
* Tested up to: 5.2.1
|
5 |
+
* Stable tag: 1.6.6
|
6 |
* Requires at least: 3.1
|
7 |
* Requires PHP: 5.2.4
|
8 |
* License: GPLv2 or later
|
266 |
|
267 |
## Changelog ##
|
268 |
|
269 |
+
### 1.6.6 ###
|
270 |
+
* Fix problems with saving settings. Returns false ONLY when there's an issue with the config file, not when the setting isn't changed. Change other code to cope with that, including updating WPCACHEHOME (#670)
|
271 |
+
* When saving settings rename the temporary config file correctly, and delete wp-admin/.php if it exists. (#673)
|
272 |
+
* Fix adding WPCACHEHOME to wp-config.php when advanced-cache.php is not found and wp-config.php is RO. (#674)
|
273 |
+
|
274 |
### 1.6.5 ###
|
275 |
* Check advanced-cache.php was created by the plugin before modifying/deleting it. (#666)
|
276 |
* When saving settings, save blank lines. Fixes problems with WP_CACHE and WPCACHEHOME in wp-config.php. Related to #652. (#667)
|
718 |
|
719 |
|
720 |
## Upgrade Notice ##
|
721 |
+
Bug fixes
|
wp-cache-phase2.php
CHANGED
@@ -1060,13 +1060,13 @@ function wp_cache_setting( $field, $value ) {
|
|
1060 |
|
1061 |
$GLOBALS[ $field ] = $value;
|
1062 |
if ( is_numeric( $value ) ) {
|
1063 |
-
wp_cache_replace_line( '^ *\$' . $field, "\$$field = $value;", $wp_cache_config_file );
|
1064 |
} elseif ( is_object( $value ) || is_array( $value ) ) {
|
1065 |
$text = var_export( $value, true );
|
1066 |
$text = preg_replace( '/[\s]+/', ' ', $text );
|
1067 |
-
wp_cache_replace_line( '^ *\$' . $field, "\$$field = $text;", $wp_cache_config_file );
|
1068 |
} else {
|
1069 |
-
wp_cache_replace_line( '^ *\$' . $field, "\$$field = '$value';", $wp_cache_config_file );
|
1070 |
}
|
1071 |
}
|
1072 |
|
@@ -1110,7 +1110,7 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
|
|
1110 |
trim( $new ) == trim( $line )
|
1111 |
) {
|
1112 |
wp_cache_debug( "wp_cache_replace_line: setting not changed - $new" );
|
1113 |
-
return
|
1114 |
} elseif ( preg_match( "/$old/", $line ) ) {
|
1115 |
wp_cache_debug( "wp_cache_replace_line: changing line " . trim( $line ) . " to *$new*" );
|
1116 |
$found = true;
|
@@ -1118,7 +1118,7 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
|
|
1118 |
}
|
1119 |
|
1120 |
$tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
|
1121 |
-
rename( $tmp_config_filename, $
|
1122 |
$tmp_config_filename .= ".php";
|
1123 |
wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
|
1124 |
$fd = fopen( $tmp_config_filename, 'w' );
|
1060 |
|
1061 |
$GLOBALS[ $field ] = $value;
|
1062 |
if ( is_numeric( $value ) ) {
|
1063 |
+
return wp_cache_replace_line( '^ *\$' . $field, "\$$field = $value;", $wp_cache_config_file );
|
1064 |
} elseif ( is_object( $value ) || is_array( $value ) ) {
|
1065 |
$text = var_export( $value, true );
|
1066 |
$text = preg_replace( '/[\s]+/', ' ', $text );
|
1067 |
+
return wp_cache_replace_line( '^ *\$' . $field, "\$$field = $text;", $wp_cache_config_file );
|
1068 |
} else {
|
1069 |
+
return wp_cache_replace_line( '^ *\$' . $field, "\$$field = '$value';", $wp_cache_config_file );
|
1070 |
}
|
1071 |
}
|
1072 |
|
1110 |
trim( $new ) == trim( $line )
|
1111 |
) {
|
1112 |
wp_cache_debug( "wp_cache_replace_line: setting not changed - $new" );
|
1113 |
+
return true;
|
1114 |
} elseif ( preg_match( "/$old/", $line ) ) {
|
1115 |
wp_cache_debug( "wp_cache_replace_line: changing line " . trim( $line ) . " to *$new*" );
|
1116 |
$found = true;
|
1118 |
}
|
1119 |
|
1120 |
$tmp_config_filename = tempnam( $GLOBALS['cache_path'], 'wpsc' );
|
1121 |
+
rename( $tmp_config_filename, $tmp_config_filename. ".php" );
|
1122 |
$tmp_config_filename .= ".php";
|
1123 |
wp_cache_debug( 'wp_cache_replace_line: writing to ' . $tmp_config_filename );
|
1124 |
$fd = fopen( $tmp_config_filename, 'w' );
|
wp-cache.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
-
Version: 1.6.
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
@@ -103,6 +103,9 @@ function wp_super_cache_init_action() {
|
|
103 |
|
104 |
wpsc_register_post_hooks();
|
105 |
|
|
|
|
|
|
|
106 |
}
|
107 |
add_action( 'init', 'wp_super_cache_init_action' );
|
108 |
|
@@ -2188,10 +2191,14 @@ function wp_cache_debug_settings() {
|
|
2188 |
function wp_cache_enable() {
|
2189 |
global $wp_cache_config_file, $cache_enabled;
|
2190 |
|
2191 |
-
if (
|
2192 |
-
|
|
|
2193 |
}
|
2194 |
|
|
|
|
|
|
|
2195 |
$cache_enabled = true;
|
2196 |
|
2197 |
if ( wpsc_set_default_gc() ) {
|
@@ -2206,10 +2213,14 @@ function wp_cache_enable() {
|
|
2206 |
function wp_cache_disable() {
|
2207 |
global $wp_cache_config_file, $cache_enabled;
|
2208 |
|
2209 |
-
if ( !
|
2210 |
-
|
|
|
2211 |
}
|
2212 |
|
|
|
|
|
|
|
2213 |
$cache_enabled = false;
|
2214 |
|
2215 |
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
|
@@ -2220,10 +2231,14 @@ function wp_cache_disable() {
|
|
2220 |
function wp_super_cache_enable() {
|
2221 |
global $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2222 |
|
2223 |
-
if (
|
2224 |
-
|
|
|
2225 |
}
|
2226 |
|
|
|
|
|
|
|
2227 |
$super_cache_enabled = true;
|
2228 |
|
2229 |
if ( is_dir( $supercachedir . '.disabled' ) ) {
|
@@ -2239,10 +2254,14 @@ function wp_super_cache_enable() {
|
|
2239 |
function wp_super_cache_disable() {
|
2240 |
global $cache_path, $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2241 |
|
2242 |
-
if ( !
|
2243 |
-
|
|
|
2244 |
}
|
2245 |
|
|
|
|
|
|
|
2246 |
$super_cache_enabled = false;
|
2247 |
|
2248 |
if ( is_dir( $supercachedir ) ) {
|
@@ -2566,7 +2585,14 @@ function wp_cache_create_advanced_cache() {
|
|
2566 |
return false;
|
2567 |
}
|
2568 |
|
2569 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2570 |
echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>";
|
2571 |
return false;
|
2572 |
}
|
@@ -2614,7 +2640,6 @@ function wp_cache_check_link() {
|
|
2614 |
echo "<li>" . sprintf( __( 'Make %1$s writable using the chmod command through your ftp or server software. (<em>chmod 777 %1$s</em>) and refresh this page. This is only a temporary measure and you’ll have to make it read only afterwards again. (Change 777 to 755 in the previous command)', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li>";
|
2615 |
echo "<li>" . sprintf( __( 'Refresh this page to update <em>%s/advanced-cache.php</em>', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li></ol>";
|
2616 |
echo sprintf( __( 'If that doesn’t work, make sure the file <em>%s/advanced-cache.php</em> doesn’t exist:', 'wp-super-cache' ), WP_CONTENT_DIR ) . "<ol>";
|
2617 |
-
printf( __( '<li>Open <em>%1$s</em> in a text editor.</li><li>Change the text <em>CACHEHOME</em> to <em>%2$s</em></li><li> Save the file and copy it to <em>%3$s</em> and refresh this page.</li>', 'wp-super-cache' ), $wp_cache_file, WPCACHEHOME, $wp_cache_link );
|
2618 |
echo "</ol>";
|
2619 |
echo "</div>";
|
2620 |
return false;
|
@@ -2630,18 +2655,21 @@ function wp_cache_check_global_config() {
|
|
2630 |
|
2631 |
|
2632 |
if ( file_exists( ABSPATH . 'wp-config.php') ) {
|
2633 |
-
$
|
2634 |
} else {
|
2635 |
-
$
|
2636 |
}
|
2637 |
|
2638 |
$line = 'define(\'WP_CACHE\', true);';
|
2639 |
-
if (
|
|
|
|
|
|
|
2640 |
if ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) {
|
2641 |
echo '<div class="notice notice-error">' . __( "<h4>WP_CACHE constant set to false</h4><p>The WP_CACHE constant is used by WordPress to load the code that serves cached pages. Unfortunately, it is set to false. Please edit your wp-config.php and add or edit the following line above the final require_once command:<br /><br /><code>define('WP_CACHE', true);</code></p>", 'wp-super-cache' ) . "</div>";
|
2642 |
} else {
|
2643 |
echo '<div class="notice notice-error"><p>' . __( "<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn’t modify it.", 'wp-super-cache' ) . "</p>";
|
2644 |
-
echo "<p>" . sprintf( __( "Edit <code>%s</code> and add the following line:<br /> <code>define('WP_CACHE', true);</code><br />Otherwise, <strong>WP-Cache will not be executed</strong> by WordPress core. ", 'wp-super-cache' ), $
|
2645 |
}
|
2646 |
return false;
|
2647 |
} else {
|
@@ -3725,11 +3753,23 @@ function wp_cache_disable_plugin( $delete_config_file = true ) {
|
|
3725 |
|
3726 |
if ( apply_filters( 'wpsc_enable_wp_config_edit', true ) ) {
|
3727 |
$line = 'define(\'WP_CACHE\', true);';
|
3728 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
3729 |
wp_die( "Could not remove WP_CACHE define from $global_config_file. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page." );
|
3730 |
}
|
3731 |
$line = 'define( \'WPCACHEHOME\',';
|
3732 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
3733 |
wp_die( "Could not remove WPCACHEHOME define from $global_config_file. Please edit that file and remove the line containing the text 'WPCACHEHOME'. Then refresh this page." );
|
3734 |
}
|
3735 |
} elseif ( function_exists( 'wp_cache_debug' ) ) {
|
@@ -4250,3 +4290,26 @@ function wpsc_get_extra_cookies() {
|
|
4250 |
return '';
|
4251 |
}
|
4252 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Plugin Name: WP Super Cache
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
|
5 |
Description: Very fast caching plugin for WordPress.
|
6 |
+
Version: 1.6.6
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
103 |
|
104 |
wpsc_register_post_hooks();
|
105 |
|
106 |
+
if ( is_admin() ) {
|
107 |
+
wpsc_fix_164();
|
108 |
+
}
|
109 |
}
|
110 |
add_action( 'init', 'wp_super_cache_init_action' );
|
111 |
|
2191 |
function wp_cache_enable() {
|
2192 |
global $wp_cache_config_file, $cache_enabled;
|
2193 |
|
2194 |
+
if ( $cache_enabled ) {
|
2195 |
+
wp_cache_debug( 'wp_cache_enable: already enabled' );
|
2196 |
+
return true;
|
2197 |
}
|
2198 |
|
2199 |
+
wp_cache_setting( 'cache_enabled', true );
|
2200 |
+
wp_cache_debug( 'wp_cache_enable: enable cache' );
|
2201 |
+
|
2202 |
$cache_enabled = true;
|
2203 |
|
2204 |
if ( wpsc_set_default_gc() ) {
|
2213 |
function wp_cache_disable() {
|
2214 |
global $wp_cache_config_file, $cache_enabled;
|
2215 |
|
2216 |
+
if ( ! $cache_enabled ) {
|
2217 |
+
wp_cache_debug( 'wp_cache_disable: already disabled' );
|
2218 |
+
return true;
|
2219 |
}
|
2220 |
|
2221 |
+
wp_cache_setting( 'cache_enabled', false );
|
2222 |
+
wp_cache_debug( 'wp_cache_disable: disable cache' );
|
2223 |
+
|
2224 |
$cache_enabled = false;
|
2225 |
|
2226 |
wp_clear_scheduled_hook( 'wp_cache_check_site_hook' );
|
2231 |
function wp_super_cache_enable() {
|
2232 |
global $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2233 |
|
2234 |
+
if ( $super_cache_enabled ) {
|
2235 |
+
wp_cache_debug( 'wp_super_cache_enable: already enabled' );
|
2236 |
+
return true;
|
2237 |
}
|
2238 |
|
2239 |
+
wp_cache_setting( 'super_cache_enabled', true );
|
2240 |
+
wp_cache_debug( 'wp_super_cache_enable: enable cache' );
|
2241 |
+
|
2242 |
$super_cache_enabled = true;
|
2243 |
|
2244 |
if ( is_dir( $supercachedir . '.disabled' ) ) {
|
2254 |
function wp_super_cache_disable() {
|
2255 |
global $cache_path, $supercachedir, $wp_cache_config_file, $super_cache_enabled;
|
2256 |
|
2257 |
+
if ( ! $super_cache_enabled ) {
|
2258 |
+
wp_cache_debug( 'wp_super_cache_disable: already disabled' );
|
2259 |
+
return true;
|
2260 |
}
|
2261 |
|
2262 |
+
wp_cache_setting( 'super_cache_enabled', false );
|
2263 |
+
wp_cache_debug( 'wp_super_cache_disable: disable cache' );
|
2264 |
+
|
2265 |
$super_cache_enabled = false;
|
2266 |
|
2267 |
if ( is_dir( $supercachedir ) ) {
|
2585 |
return false;
|
2586 |
}
|
2587 |
|
2588 |
+
$file = file_get_contents( $global_config_file );
|
2589 |
+
if (
|
2590 |
+
! strpos( $file, "WPCACHEHOME" ) &&
|
2591 |
+
(
|
2592 |
+
! is_writeable_ACLSafe( $global_config_file ) ||
|
2593 |
+
! wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', $line, $global_config_file )
|
2594 |
+
)
|
2595 |
+
) {
|
2596 |
echo '<div class="notice notice-error"><h4>' . __( 'Warning', 'wp-super-cache' ) . "! <em>" . sprintf( __( 'Could not update %s!</em> WPCACHEHOME must be set in config file.', 'wp-super-cache' ), $global_config_file ) . "</h4></div>";
|
2597 |
return false;
|
2598 |
}
|
2640 |
echo "<li>" . sprintf( __( 'Make %1$s writable using the chmod command through your ftp or server software. (<em>chmod 777 %1$s</em>) and refresh this page. This is only a temporary measure and you’ll have to make it read only afterwards again. (Change 777 to 755 in the previous command)', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li>";
|
2641 |
echo "<li>" . sprintf( __( 'Refresh this page to update <em>%s/advanced-cache.php</em>', 'wp-super-cache' ), WP_CONTENT_DIR ) . "</li></ol>";
|
2642 |
echo sprintf( __( 'If that doesn’t work, make sure the file <em>%s/advanced-cache.php</em> doesn’t exist:', 'wp-super-cache' ), WP_CONTENT_DIR ) . "<ol>";
|
|
|
2643 |
echo "</ol>";
|
2644 |
echo "</div>";
|
2645 |
return false;
|
2655 |
|
2656 |
|
2657 |
if ( file_exists( ABSPATH . 'wp-config.php') ) {
|
2658 |
+
$global_config_file = ABSPATH . 'wp-config.php';
|
2659 |
} else {
|
2660 |
+
$global_config_file = dirname( ABSPATH ) . '/wp-config.php';
|
2661 |
}
|
2662 |
|
2663 |
$line = 'define(\'WP_CACHE\', true);';
|
2664 |
+
if (
|
2665 |
+
! is_writeable_ACLSafe( $global_config_file ) ||
|
2666 |
+
! wp_cache_replace_line( 'define *\( *\'WP_CACHE\'', $line, $global_config_file )
|
2667 |
+
) {
|
2668 |
if ( defined( 'WP_CACHE' ) && constant( 'WP_CACHE' ) == false ) {
|
2669 |
echo '<div class="notice notice-error">' . __( "<h4>WP_CACHE constant set to false</h4><p>The WP_CACHE constant is used by WordPress to load the code that serves cached pages. Unfortunately, it is set to false. Please edit your wp-config.php and add or edit the following line above the final require_once command:<br /><br /><code>define('WP_CACHE', true);</code></p>", 'wp-super-cache' ) . "</div>";
|
2670 |
} else {
|
2671 |
echo '<div class="notice notice-error"><p>' . __( "<strong>Error: WP_CACHE is not enabled</strong> in your <code>wp-config.php</code> file and I couldn’t modify it.", 'wp-super-cache' ) . "</p>";
|
2672 |
+
echo "<p>" . sprintf( __( "Edit <code>%s</code> and add the following line:<br /> <code>define('WP_CACHE', true);</code><br />Otherwise, <strong>WP-Cache will not be executed</strong> by WordPress core. ", 'wp-super-cache' ), $global_config_file ) . "</p></div>";
|
2673 |
}
|
2674 |
return false;
|
2675 |
} else {
|
3753 |
|
3754 |
if ( apply_filters( 'wpsc_enable_wp_config_edit', true ) ) {
|
3755 |
$line = 'define(\'WP_CACHE\', true);';
|
3756 |
+
if (
|
3757 |
+
strpos( file_get_contents( $global_config_file ), $line ) &&
|
3758 |
+
(
|
3759 |
+
! is_writeable_ACLSafe( $global_config_file ) ||
|
3760 |
+
! wp_cache_replace_line( 'define*\(*\'WP_CACHE\'', '', $global_config_file )
|
3761 |
+
)
|
3762 |
+
) {
|
3763 |
wp_die( "Could not remove WP_CACHE define from $global_config_file. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page." );
|
3764 |
}
|
3765 |
$line = 'define( \'WPCACHEHOME\',';
|
3766 |
+
if (
|
3767 |
+
strpos( file_get_contents( $global_config_file ), $line ) &&
|
3768 |
+
(
|
3769 |
+
! is_writeable_ACLSafe( $global_config_file ) ||
|
3770 |
+
! wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', '', $global_config_file )
|
3771 |
+
)
|
3772 |
+
) {
|
3773 |
wp_die( "Could not remove WPCACHEHOME define from $global_config_file. Please edit that file and remove the line containing the text 'WPCACHEHOME'. Then refresh this page." );
|
3774 |
}
|
3775 |
} elseif ( function_exists( 'wp_cache_debug' ) ) {
|
4290 |
return '';
|
4291 |
}
|
4292 |
}
|
4293 |
+
|
4294 |
+
/*
|
4295 |
+
* 1.6.4 created an empty file called wp-admin/.php that must be cleaned up.
|
4296 |
+
*/
|
4297 |
+
function wpsc_fix_164() {
|
4298 |
+
global $wpsc_fix_164;
|
4299 |
+
|
4300 |
+
if (
|
4301 |
+
isset( $wpsc_fix_164 ) &&
|
4302 |
+
$wpsc_fix_164
|
4303 |
+
) {
|
4304 |
+
return false;
|
4305 |
+
}
|
4306 |
+
|
4307 |
+
if (
|
4308 |
+
file_exists( ABSPATH . '/wp-admin/.php' ) &&
|
4309 |
+
0 == filesize( ABSPATH . '/wp-admin/.php' )
|
4310 |
+
) {
|
4311 |
+
@unlink( ABSPATH . '/wp-admin/.php' );
|
4312 |
+
}
|
4313 |
+
|
4314 |
+
wp_cache_setting( 'wpsc_fix_164', 1 );
|
4315 |
+
}
|