WP Super Cache - Version 1.6.1

Version Description

Download this release

Release Info

Developer donncha
Plugin Icon 128x128 WP Super Cache
Version 1.6.1
Comparing to
See all releases

Code changes from version 1.6.0 to 1.6.1

Files changed (4) hide show
  1. readme.txt +6 -2
  2. rest/load.php +1 -1
  3. wp-cache-phase2.php +17 -2
  4. wp-cache.php +40 -9
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  * Contributors: donncha, automattic, kraftbj
3
  * Tags: performance, caching, wp-cache, wp-super-cache, cache
4
  * Tested up to: 4.9.5
5
- * Stable tag: 1.6.0
6
  * Requires at least: 3.0
7
  * Requires PHP: 5.2.4
8
  * License: GPLv2 or later
@@ -261,6 +261,10 @@ Your theme is probably responsive which means it resizes the page to suit whatev
261
 
262
  ## Changelog ##
263
 
 
 
 
 
264
 
265
  ### 1.6.0 ###
266
  * Fix issues in multisite plugin (#501)
@@ -280,7 +284,7 @@ Your theme is probably responsive which means it resizes the page to suit whatev
280
  * Add ipad to mobile list (#525)
281
  * Hide opcache_invalidate() warnings since it's disabled some places. (#543)
282
  * Check that HTTP_REFERER exists before checking it. (#544)
283
- * Replace Cron View" with WP Control because it's still updated. (#546)
284
  * adding hook (wp_cache_cleared) for full cache purges (#537)
285
 
286
 
2
  * Contributors: donncha, automattic, kraftbj
3
  * Tags: performance, caching, wp-cache, wp-super-cache, cache
4
  * Tested up to: 4.9.5
5
+ * Stable tag: 1.6.1
6
  * Requires at least: 3.0
7
  * Requires PHP: 5.2.4
8
  * License: GPLv2 or later
261
 
262
  ## Changelog ##
263
 
264
+ ### 1.6.1 ###
265
+ * Fix the name of the WP Crontrol plugin. (#549)
266
+ * Handle errors during deactivation/uninstall by email rather than exiting. (#551)
267
+ * Add a notice when settings can't be updated. (#552 and #553)
268
 
269
  ### 1.6.0 ###
270
  * Fix issues in multisite plugin (#501)
284
  * Add ipad to mobile list (#525)
285
  * Hide opcache_invalidate() warnings since it's disabled some places. (#543)
286
  * Check that HTTP_REFERER exists before checking it. (#544)
287
+ * Replace Cron View" with WP Crontrol because it's still updated. (#546)
288
  * adding hook (wp_cache_cleared) for full cache purges (#537)
289
 
290
 
rest/load.php CHANGED
@@ -35,7 +35,7 @@ class WP_Super_Cache_Router {
35
  $preload_cache = new WP_Super_Cache_Rest_Preload();
36
  $get_status = new WP_Super_Cache_Rest_Get_Status();
37
  $get_plugins = new WP_Super_Cache_Rest_Get_Plugins();
38
- $update_plugins = new WP_Super_Cache_Rest_Update_plugins();
39
 
40
  register_rest_route( $namespace, '/settings', array(
41
  array(
35
  $preload_cache = new WP_Super_Cache_Rest_Preload();
36
  $get_status = new WP_Super_Cache_Rest_Get_Status();
37
  $get_plugins = new WP_Super_Cache_Rest_Get_Plugins();
38
+ $update_plugins = new WP_Super_Cache_Rest_Update_Plugins();
39
 
40
  register_rest_route( $namespace, '/settings', array(
41
  array(
wp-cache-phase2.php CHANGED
@@ -1046,13 +1046,22 @@ function wp_cache_setting( $field, $value ) {
1046
 
1047
  function wp_cache_replace_line( $old, $new, $my_file ) {
1048
  if ( @is_file( $my_file ) == false ) {
 
1049
  return false;
1050
  }
1051
  if (!is_writeable_ACLSafe($my_file)) {
 
1052
  trigger_error( "Error: file $my_file is not writable." );
1053
  return false;
1054
  }
1055
 
 
 
 
 
 
 
 
1056
  $found = false;
1057
  $loaded = false;
1058
  $c = 0;
@@ -1064,6 +1073,7 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
1064
  } else {
1065
  $c++;
1066
  if ( $c > 100 ) {
 
1067
  trigger_error( "wp_cache_replace_line: Error - file $my_file could not be loaded." );
1068
  return false;
1069
  }
@@ -1076,9 +1086,9 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
1076
  }
1077
  }
1078
 
1079
- $tmp_file = dirname( $my_file ) . '/' . mt_rand() . '.php';
1080
  $fd = fopen( $tmp_file, 'w' );
1081
  if ( ! $fd ) {
 
1082
  trigger_error( "wp_cache_replace_line: Error - could not write to $tmp_file" );
1083
  return false;
1084
  }
@@ -1103,7 +1113,12 @@ function wp_cache_replace_line( $old, $new, $my_file ) {
1103
  }
1104
  }
1105
  fclose( $fd );
1106
- @rename( $tmp_file, $my_file );
 
 
 
 
 
1107
 
1108
  if ( function_exists( "opcache_invalidate" ) ) {
1109
  @opcache_invalidate( $my_file );
1046
 
1047
  function wp_cache_replace_line( $old, $new, $my_file ) {
1048
  if ( @is_file( $my_file ) == false ) {
1049
+ set_transient( 'wpsc_config_error', 'config_file_missing', 10 );
1050
  return false;
1051
  }
1052
  if (!is_writeable_ACLSafe($my_file)) {
1053
+ set_transient( 'wpsc_config_error', 'config_file_ro', 10 );
1054
  trigger_error( "Error: file $my_file is not writable." );
1055
  return false;
1056
  }
1057
 
1058
+ $tmp_file = tempnam( sys_get_temp_dir(), 'wpsc' );
1059
+ if ( ! is_writeable_ACLSafe( $tmp_file ) ) {
1060
+ set_transient( 'wpsc_config_error', 'tmp_file_ro', 10 );
1061
+ trigger_error( "Error: temporary file $tmp_file is not writable. Make sure directory is writeable." );
1062
+ return false;
1063
+ }
1064
+
1065
  $found = false;
1066
  $loaded = false;
1067
  $c = 0;
1073
  } else {
1074
  $c++;
1075
  if ( $c > 100 ) {
1076
+ set_transient( 'wpsc_config_error', 'config_file_not_loaded', 10 );
1077
  trigger_error( "wp_cache_replace_line: Error - file $my_file could not be loaded." );
1078
  return false;
1079
  }
1086
  }
1087
  }
1088
 
 
1089
  $fd = fopen( $tmp_file, 'w' );
1090
  if ( ! $fd ) {
1091
+ set_transient( 'wpsc_config_error', 'config_file_ro', 10 );
1092
  trigger_error( "wp_cache_replace_line: Error - could not write to $tmp_file" );
1093
  return false;
1094
  }
1113
  }
1114
  }
1115
  fclose( $fd );
1116
+
1117
+ if ( ! rename( $tmp_file, $my_file ) ) {
1118
+ set_transient( 'wpsc_config_error', 'error_move_tmp_config_file', 10 );
1119
+ trigger_error( "wp_cache_replace_line: Error - could not rename $tmp_file to $my_file" );
1120
+ return false;
1121
+ }
1122
 
1123
  if ( function_exists( "opcache_invalidate" ) ) {
1124
  @opcache_invalidate( $my_file );
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.0
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
@@ -1276,7 +1276,7 @@ table.wpsc-settings-table {
1276
  <li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://yslow.org/', 'https://gtmetrix.com/' ); ?></li>
1277
  <li><?php printf( __( '<a href="%s">Use Google Libraries</a> allows you to load some commonly used Javascript libraries from Google webservers. Ironically, it may reduce your Yslow score.', 'wp-super-cache' ), 'https://wordpress.org/plugins/use-google-libraries/' ); ?></li>
1278
  <li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'https://wordpress.org/plugins/memcached/', 'https://neosmart.net/WP/XCache/', 'https://neosmart.net/WP/eAccelerator/' ); ?></li>
1279
- <li><?php printf( __( '<a href="%s">WP Control</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-crontrol/' ); ?></li>
1280
  </ul>
1281
 
1282
  <?php
@@ -2292,6 +2292,37 @@ function wp_cache_index_notice() {
2292
  }
2293
  add_action( 'admin_notices', 'wp_cache_index_notice' );
2294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2295
  function wpsc_dismiss_indexhtml_warning() {
2296
  check_ajax_referer( "wpsc-index-dismiss" );
2297
  update_site_option( 'wp_super_cache_index_detected', 3 );
@@ -3601,16 +3632,16 @@ function wp_cache_disable_plugin( $delete_config_file = true ) {
3601
  $file_not_deleted[] = 'wp-cache-config.php';
3602
  }
3603
  if ( $file_not_deleted ) {
3604
- $msg = "<p>One or more files could not be deleted. These files and directories must be made writeable:</p>\n <ol><li>" . WP_CONTENT_DIR . "</li>\n";
3605
- $code = "<ul>\n";
3606
  foreach( (array)$file_not_deleted as $filename ) {
3607
- $msg .= "<li>" . WP_CONTENT_DIR . "/{$filename}</li>";
3608
- $code .= "<li><code>chmod 666 " . WP_CONTENT_DIR . "/{$filename}</code></li>\n";
3609
  }
3610
- $code .= "</ul>\n";
 
3611
 
3612
- $msg .= "</ol>\n<p>First try fixing the directory permissions with this command and refresh this page:<br /><br /><code>chmod 777 " . WP_CONTENT_DIR . "</code><br /><br />If you still see this error, you have to fix the permissions on the files themselves and refresh this page again:</p> {$code}\n<p>Don't forget to fix things later:<br /><code>chmod 755 " . WP_CONTENT_DIR . "</code></p><p>If you don't know what <strong>chmod</strong> is read all about it <a href='https://codex.wordpress.org/Changing_File_Permissions#About_Chmod'>here</a> and note the warning about using 777 permission.</p><p>Please refresh this page when the permissions have been modified.</p>";
3613
- wp_die( $msg );
 
3614
  }
3615
  extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3616
  if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {
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.1
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
1276
  <li><?php printf( __( '<a href="%s">Yahoo! Yslow</a> analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages. Also try the performance tools online at <a href="%s">GTMetrix</a>.', 'wp-super-cache' ), 'http://yslow.org/', 'https://gtmetrix.com/' ); ?></li>
1277
  <li><?php printf( __( '<a href="%s">Use Google Libraries</a> allows you to load some commonly used Javascript libraries from Google webservers. Ironically, it may reduce your Yslow score.', 'wp-super-cache' ), 'https://wordpress.org/plugins/use-google-libraries/' ); ?></li>
1278
  <li><?php printf( __( '<strong>Advanced users only:</strong> Install an object cache. Choose from <a href="%s">Memcached</a>, <a href="%s">XCache</a>, <a href="%s">eAcccelerator</a> and others.', 'wp-super-cache' ), 'https://wordpress.org/plugins/memcached/', 'https://neosmart.net/WP/XCache/', 'https://neosmart.net/WP/eAccelerator/' ); ?></li>
1279
+ <li><?php printf( __( '<a href="%s">WP Crontrol</a> is a useful plugin to use when trying to debug garbage collection and preload problems.', 'wp-super-cache' ), 'https://wordpress.org/plugins/wp-crontrol/' ); ?></li>
1280
  </ul>
1281
 
1282
  <?php
2292
  }
2293
  add_action( 'admin_notices', 'wp_cache_index_notice' );
2294
 
2295
+ function wpsc_config_file_notices() {
2296
+ global $wp_cache_config_file;
2297
+ if ( ! isset( $_GET['page'] ) || $_GET['page'] != 'wpsupercache' ) {
2298
+ return false;
2299
+ }
2300
+ $notice = get_transient( 'wpsc_config_error' );
2301
+ if ( ! $notice ) {
2302
+ return false;
2303
+ }
2304
+ switch( $notice ) {
2305
+ case 'error_move_tmp_config_file':
2306
+ $msg = sprintf( __( 'Error: Could not rename temporary file to configuration file. Please make sure %s is writeable by the webserver.' ), $wp_cache_config_file );
2307
+ break;
2308
+ case 'config_file_ro':
2309
+ $msg = sprintf( __( 'Error: Configuration file is read only. Please make sure %s is writeable by the webserver.' ), $wp_cache_config_file );
2310
+ break;
2311
+ case 'tmp_file_ro':
2312
+ $msg = sprintf( __( 'Error: The directory containing the configuration file %s is read only. Please make sure it is writeable by the webserver.' ), $wp_cache_config_file );
2313
+ break;
2314
+ case 'config_file_not_loaded':
2315
+ $msg = sprintf( __( 'Error: Configuration file %s could not be loaded. Please reload the page.' ), $wp_cache_config_file );
2316
+ break;
2317
+ case 'config_file_missing':
2318
+ $msg = sprintf( __( 'Error: Configuration file %s s missing. Please reload the page.' ), $wp_cache_config_file );
2319
+ break;
2320
+
2321
+ }
2322
+ echo '<div class="error"><p><strong>' . $msg . '</strong></p></div>';
2323
+ }
2324
+ add_action( 'admin_notices', 'wpsc_config_file_notices' );
2325
+
2326
  function wpsc_dismiss_indexhtml_warning() {
2327
  check_ajax_referer( "wpsc-index-dismiss" );
2328
  update_site_option( 'wp_super_cache_index_detected', 3 );
3632
  $file_not_deleted[] = 'wp-cache-config.php';
3633
  }
3634
  if ( $file_not_deleted ) {
3635
+ $msg = __( "Dear User,\n\nWP Super Cache was removed from your blog or deactivated but some files could\nnot be deleted.\n\n", 'wp-super-cache' );
 
3636
  foreach( (array)$file_not_deleted as $filename ) {
3637
+ $msg .= WP_CONTENT_DIR . "/{$filename}\n";
 
3638
  }
3639
+ $msg .= "\n";
3640
+ $msg .= sprintf( __( "You should delete these files manually.\nYou may need to change the permissions of the files or parent directory.\nYou can read more about this in the Codex at\n%s\n\nThank you.", 'wp-super-cache' ), 'https://codex.wordpress.org/Changing_File_Permissions#About_Chmod' );
3641
 
3642
+ if ( apply_filters( 'wpsc_send_uninstall_errors', 1 ) ) {
3643
+ wp_mail( get_option( 'admin_email' ), __( 'WP Super Cache: could not delete files', 'wp-super-cache' ), $msg );
3644
+ }
3645
  }
3646
  extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3647
  if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {