WP Super Cache - Version 1.5.7.1

Version Description

  • If the HTTP HOST is empty then don't use it in strpos to avoid a PHP warning. (#408)
  • Don't preload posts with permalinks that contain rejected strings. (#407)
  • Generate a list of archive feeds that can be deleted when the site is updated. Also fixes corrupted config file issue and fatal error with older versions of WordPress. (#403)
Download this release

Release Info

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

Code changes from version 1.5.7 to 1.5.7.1

Files changed (4) hide show
  1. readme.txt +8 -3
  2. wp-cache-phase1.php +1 -17
  3. wp-cache-phase2.php +14 -1
  4. wp-cache.php +22 -5
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: 4.8.1
5
- Stable tag: 1.5.7
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
@@ -53,9 +53,14 @@ Interested in translating WP Super Cache to your language? See the [translation
53
  The cache directory, usually wp-content/cache/ is only for temporary files. Do not ever put important files or symlinks to important files or directories in that directory. They will be deleted if the plugin has write access to them.
54
 
55
  == Upgrade Notice ==
56
- Fixes fatal error for users who toggled the "no adverts for friends" plugin.
57
 
58
  == Changelog ==
 
 
 
 
 
59
  = 1.5.7 =
60
  * Fix fatal error in plugins/searchengine.php (#398)
61
 
1
  === WP Super Cache ===
2
  Contributors: donncha, automattic, kraftbj
3
  Tags: performance,caching,wp-cache,wp-super-cache,cache
4
+ Tested up to: 4.8.2
5
+ Stable tag: 1.5.7.1
6
  Requires at least: 3.0
7
 
8
  A very fast caching engine for WordPress that produces static html files.
53
  The cache directory, usually wp-content/cache/ is only for temporary files. Do not ever put important files or symlinks to important files or directories in that directory. They will be deleted if the plugin has write access to them.
54
 
55
  == Upgrade Notice ==
56
+ Fixes fatal error for older versions of WP and corrupted config file issues.
57
 
58
  == Changelog ==
59
+ = 1.5.7.1 =
60
+ * If the HTTP HOST is empty then don't use it in strpos to avoid a PHP warning. (#408)
61
+ * Don't preload posts with permalinks that contain rejected strings. (#407)
62
+ * Generate a list of archive feeds that can be deleted when the site is updated. Also fixes corrupted config file issue and fatal error with older versions of WordPress. (#403)
63
+
64
  = 1.5.7 =
65
  * Fix fatal error in plugins/searchengine.php (#398)
66
 
wp-cache-phase1.php CHANGED
@@ -194,22 +194,6 @@ function wp_cache_serve_cache_file() {
194
  @unlink( $cache_file );
195
  return true;
196
  }
197
- // check for updated feed
198
- if ( isset( $meta[ 'headers' ][ 'Content-Type' ] ) ) {
199
- $rss_types = apply_filters( 'wpsc_rss_types', array( 'application/rss+xml', 'application/rdf+xml', 'application/atom+xml' ) );
200
- foreach( $rss_types as $rss_type ) {
201
- if ( strpos( $meta[ 'headers' ][ 'Content-Type' ], $rss_type ) ) {
202
- global $wpsc_last_post_update;
203
- if ( isset( $wpsc_last_post_update ) && filemtime( $meta_pathname ) < $wpsc_last_post_update ||
204
- ( isset( $meta[ 'ttl' ] ) && ( time() - filemtime( $meta_pathname ) ) > $meta[ 'ttl' ] ) ) {
205
- wp_cache_debug( "wp_cache_serve_cache_file: feed out of date. deleting cache files: $meta_pathname, $cache_file" );
206
- @unlink( $meta_pathname );
207
- @unlink( $cache_file );
208
- return true;
209
- }
210
- }
211
- }
212
- }
213
  } else { // no $cache_file
214
  global $wpsc_save_headers;
215
  // last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
@@ -633,7 +617,7 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
633
  */
634
  $DONOTREMEMBER = 1;
635
  wp_cache_debug( "get_current_url_supercache_dir: warning! site_url ($site_url) not found in permalink ($permalink).", 1 );
636
- if ( false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
637
  wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$WPSC_HTTP_HOST}) not found in permalink ($permalink). ", 1 );
638
  $p = parse_url( $permalink );
639
  if ( is_array( $p ) ) {
194
  @unlink( $cache_file );
195
  return true;
196
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  } else { // no $cache_file
198
  global $wpsc_save_headers;
199
  // last chance, check if a supercache file exists. Just in case .htaccess rules don't work on this host
617
  */
618
  $DONOTREMEMBER = 1;
619
  wp_cache_debug( "get_current_url_supercache_dir: warning! site_url ($site_url) not found in permalink ($permalink).", 1 );
620
+ if ( $WPSC_HTTP_HOST == '' || false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
621
  wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$WPSC_HTTP_HOST}) not found in permalink ($permalink). ", 1 );
622
  $p = parse_url( $permalink );
623
  if ( is_array( $p ) ) {
wp-cache-phase2.php CHANGED
@@ -433,7 +433,7 @@ function wp_cache_ob_callback( $buffer ) {
433
  } elseif ( isset( $_GET[ 'preview' ] ) ) {
434
  wp_cache_debug( 'Not caching preview post.', 2 );
435
  $cache_this_page = false;
436
- } elseif ( !in_array($script, $cache_acceptable_files) && wp_cache_is_rejected( $wp_cache_request_uri ) ) {
437
  wp_cache_debug( 'URI rejected. Not Caching', 2 );
438
  $cache_this_page = false;
439
  } elseif ( wp_cache_user_agent_is_rejected() ) {
@@ -1150,6 +1150,7 @@ function wp_cache_shutdown_callback() {
1150
  /* @header('Last-Modified: ' . $value); */
1151
  $wp_cache_meta[ 'headers' ][ 'Last-Modified' ] = "Last-Modified: $value";
1152
  }
 
1153
  if ( !isset( $response[ 'Content-Type' ] ) && !isset( $response[ 'Content-type' ] ) ) {
1154
  // On some systems, headers set by PHP can't be fetched from
1155
  // the output buffer. This is a last ditch effort to set the
@@ -1181,6 +1182,7 @@ function wp_cache_shutdown_callback() {
1181
  if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
1182
  $wp_cache_meta[ 'ttl' ] = 60;
1183
  }
 
1184
 
1185
  wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
1186
  } elseif ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
@@ -1189,6 +1191,7 @@ function wp_cache_shutdown_callback() {
1189
  if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
1190
  $wp_cache_meta[ 'ttl' ] = 60;
1191
  }
 
1192
 
1193
  } else { // not a feed
1194
  $value = get_option( 'html_type' );
@@ -1238,6 +1241,16 @@ function wp_cache_shutdown_callback() {
1238
  wp_cache_set( $oc_key, $serial, 'supercache', $cache_max_time );
1239
  }
1240
  wp_cache_writers_exit();
 
 
 
 
 
 
 
 
 
 
1241
  }
1242
  } else {
1243
  wp_cache_debug( "Did not write meta file: meta-{$meta_file} *$supercacheonly* *$wp_cache_not_logged_in* *$new_cache*", 2 );
433
  } elseif ( isset( $_GET[ 'preview' ] ) ) {
434
  wp_cache_debug( 'Not caching preview post.', 2 );
435
  $cache_this_page = false;
436
+ } elseif ( !in_array( $script, (array) $cache_acceptable_files ) && wp_cache_is_rejected( $wp_cache_request_uri ) ) {
437
  wp_cache_debug( 'URI rejected. Not Caching', 2 );
438
  $cache_this_page = false;
439
  } elseif ( wp_cache_user_agent_is_rejected() ) {
1150
  /* @header('Last-Modified: ' . $value); */
1151
  $wp_cache_meta[ 'headers' ][ 'Last-Modified' ] = "Last-Modified: $value";
1152
  }
1153
+ $is_feed = false;
1154
  if ( !isset( $response[ 'Content-Type' ] ) && !isset( $response[ 'Content-type' ] ) ) {
1155
  // On some systems, headers set by PHP can't be fetched from
1156
  // the output buffer. This is a last ditch effort to set the
1182
  if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
1183
  $wp_cache_meta[ 'ttl' ] = 60;
1184
  }
1185
+ $is_feed = true;
1186
 
1187
  wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
1188
  } elseif ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
1191
  if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
1192
  $wp_cache_meta[ 'ttl' ] = 60;
1193
  }
1194
+ $is_feed = true;
1195
 
1196
  } else { // not a feed
1197
  $value = get_option( 'html_type' );
1241
  wp_cache_set( $oc_key, $serial, 'supercache', $cache_max_time );
1242
  }
1243
  wp_cache_writers_exit();
1244
+
1245
+ // record locations of archive feeds to be updated when the site is updated.
1246
+ // Only record a maximum of 50 feeds to avoid bloating database.
1247
+ if ( ( isset( $wp_super_cache_query[ 'is_feed' ] ) || $is_feed ) && ! isset( $wp_super_cache_query[ 'is_single' ] ) ) {
1248
+ $wpsc_feed_list = (array) get_option( 'wpsc_feed_list' );
1249
+ if ( count( $wpsc_feed_list ) <= 50 ) {
1250
+ $wpsc_feed_list[] = $dir . $meta_file;
1251
+ update_option( 'wpsc_feed_list', $wpsc_feed_list );
1252
+ }
1253
+ }
1254
  }
1255
  } else {
1256
  wp_cache_debug( "Did not write meta file: meta-{$meta_file} *$supercacheonly* *$wp_cache_not_logged_in* *$new_cache*", 2 );
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.5.7
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
@@ -3502,8 +3502,13 @@ function wp_cron_preload_cache() {
3502
  set_time_limit( 60 );
3503
  if ( $page_on_front != 0 && ( $post_id == $page_on_front || $post_id == $page_for_posts ) )
3504
  continue;
3505
- clear_post_supercache( $post_id );
3506
  $url = get_permalink( $post_id );
 
 
 
 
 
 
3507
  $fp = @fopen( $permalink_counter_msg, 'w' );
3508
  if ( $fp ) {
3509
  @fwrite( $fp, $count . " " . $url );
@@ -3979,10 +3984,22 @@ function update_mod_rewrite_rules( $add_rules = true ) {
3979
  return true;
3980
  }
3981
 
3982
- function wpsc_timestamp_cache_update( $type, $permalink ) {
3983
- wp_cache_setting( 'wpsc_last_post_update', time() );
 
 
 
 
 
 
 
 
 
 
 
 
3984
  }
3985
- add_action( 'gc_cache', 'wpsc_timestamp_cache_update', 10, 2 );
3986
 
3987
  function wpsc_get_plugin_list() {
3988
  $list = do_cacheaction( 'wpsc_filter_list' );
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.5.7.1
7
  Author: Automattic
8
  Author URI: https://automattic.com/
9
  License: GPL2+
3502
  set_time_limit( 60 );
3503
  if ( $page_on_front != 0 && ( $post_id == $page_on_front || $post_id == $page_for_posts ) )
3504
  continue;
 
3505
  $url = get_permalink( $post_id );
3506
+
3507
+ if ( wp_cache_is_rejected( $url ) ) {
3508
+ wp_cache_debug( "wp_cron_preload_cache: skipped $url per rejected strings setting" );
3509
+ continue;
3510
+ }
3511
+ clear_post_supercache( $post_id );
3512
  $fp = @fopen( $permalink_counter_msg, 'w' );
3513
  if ( $fp ) {
3514
  @fwrite( $fp, $count . " " . $url );
3984
  return true;
3985
  }
3986
 
3987
+ // Delete feeds when the site is updated so that feed files are always fresh
3988
+ function wpsc_feed_update( $type, $permalink ) {
3989
+ $wpsc_feed_list = get_option( 'wpsc_feed_list' );
3990
+
3991
+ update_option( 'wpsc_feed_list', array() );
3992
+ if ( is_array( $wpsc_feed_list ) && ! empty( $wpsc_feed_list ) ) {
3993
+ if ( ! function_exists( 'prune_super_cache' ) )
3994
+ include_once( 'wp-cache-phase2.php' );
3995
+ foreach( $wpsc_feed_list as $file ) {
3996
+ wp_cache_debug( "wpsc_feed_update: deleting feed: $file" );
3997
+ prune_super_cache( $file, true );
3998
+ prune_super_cache( dirname( $file ) . '/meta-' . basename( $file ), true );
3999
+ }
4000
+ }
4001
  }
4002
+ add_action( 'gc_cache', 'wpsc_feed_update', 10, 2 );
4003
 
4004
  function wpsc_get_plugin_list() {
4005
  $list = do_cacheaction( 'wpsc_filter_list' );