Commit df01da35 authored by lucha's avatar lucha

[auto] plugin: wp-super-cache 1.5.7.1

parent 0462d3a1
=== WP Super Cache ===
Contributors: donncha, automattic, kraftbj
Tags: performance,caching,wp-cache,wp-super-cache,cache
Tested up to: 4.8.1
Stable tag: 1.5.7
Tested up to: 4.8.2
Stable tag: 1.5.7.1
Requires at least: 3.0
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
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.
== Upgrade Notice ==
Fixes fatal error for users who toggled the "no adverts for friends" plugin.
Fixes fatal error for older versions of WP and corrupted config file issues.
== Changelog ==
= 1.5.7.1 =
* 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)
= 1.5.7 =
* Fix fatal error in plugins/searchengine.php (#398)
......
......@@ -194,22 +194,6 @@ function wp_cache_serve_cache_file() {
@unlink( $cache_file );
return true;
}
// check for updated feed
if ( isset( $meta[ 'headers' ][ 'Content-Type' ] ) ) {
$rss_types = apply_filters( 'wpsc_rss_types', array( 'application/rss+xml', 'application/rdf+xml', 'application/atom+xml' ) );
foreach( $rss_types as $rss_type ) {
if ( strpos( $meta[ 'headers' ][ 'Content-Type' ], $rss_type ) ) {
global $wpsc_last_post_update;
if ( isset( $wpsc_last_post_update ) && filemtime( $meta_pathname ) < $wpsc_last_post_update ||
( isset( $meta[ 'ttl' ] ) && ( time() - filemtime( $meta_pathname ) ) > $meta[ 'ttl' ] ) ) {
wp_cache_debug( "wp_cache_serve_cache_file: feed out of date. deleting cache files: $meta_pathname, $cache_file" );
@unlink( $meta_pathname );
@unlink( $cache_file );
return true;
}
}
}
}
} else { // no $cache_file
global $wpsc_save_headers;
// 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 ) {
*/
$DONOTREMEMBER = 1;
wp_cache_debug( "get_current_url_supercache_dir: warning! site_url ($site_url) not found in permalink ($permalink).", 1 );
if ( false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
if ( $WPSC_HTTP_HOST == '' || false === strpos( $permalink, $WPSC_HTTP_HOST ) ) {
wp_cache_debug( "get_current_url_supercache_dir: WARNING! SERVER_NAME ({$WPSC_HTTP_HOST}) not found in permalink ($permalink). ", 1 );
$p = parse_url( $permalink );
if ( is_array( $p ) ) {
......
......@@ -433,7 +433,7 @@ function wp_cache_ob_callback( $buffer ) {
} elseif ( isset( $_GET[ 'preview' ] ) ) {
wp_cache_debug( 'Not caching preview post.', 2 );
$cache_this_page = false;
} elseif ( !in_array($script, $cache_acceptable_files) && wp_cache_is_rejected( $wp_cache_request_uri ) ) {
} elseif ( !in_array( $script, (array) $cache_acceptable_files ) && wp_cache_is_rejected( $wp_cache_request_uri ) ) {
wp_cache_debug( 'URI rejected. Not Caching', 2 );
$cache_this_page = false;
} elseif ( wp_cache_user_agent_is_rejected() ) {
......@@ -1150,6 +1150,7 @@ function wp_cache_shutdown_callback() {
/* @header('Last-Modified: ' . $value); */
$wp_cache_meta[ 'headers' ][ 'Last-Modified' ] = "Last-Modified: $value";
}
$is_feed = false;
if ( !isset( $response[ 'Content-Type' ] ) && !isset( $response[ 'Content-type' ] ) ) {
// On some systems, headers set by PHP can't be fetched from
// the output buffer. This is a last ditch effort to set the
......@@ -1181,6 +1182,7 @@ function wp_cache_shutdown_callback() {
if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
$wp_cache_meta[ 'ttl' ] = 60;
}
$is_feed = true;
wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
} elseif ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
......@@ -1189,6 +1191,7 @@ function wp_cache_shutdown_callback() {
if ( isset( $wpsc_feed_ttl ) && $wpsc_feed_ttl == 1 ) {
$wp_cache_meta[ 'ttl' ] = 60;
}
$is_feed = true;
} else { // not a feed
$value = get_option( 'html_type' );
......@@ -1238,6 +1241,16 @@ function wp_cache_shutdown_callback() {
wp_cache_set( $oc_key, $serial, 'supercache', $cache_max_time );
}
wp_cache_writers_exit();
// record locations of archive feeds to be updated when the site is updated.
// Only record a maximum of 50 feeds to avoid bloating database.
if ( ( isset( $wp_super_cache_query[ 'is_feed' ] ) || $is_feed ) && ! isset( $wp_super_cache_query[ 'is_single' ] ) ) {
$wpsc_feed_list = (array) get_option( 'wpsc_feed_list' );
if ( count( $wpsc_feed_list ) <= 50 ) {
$wpsc_feed_list[] = $dir . $meta_file;
update_option( 'wpsc_feed_list', $wpsc_feed_list );
}
}
}
} else {
wp_cache_debug( "Did not write meta file: meta-{$meta_file} *$supercacheonly* *$wp_cache_not_logged_in* *$new_cache*", 2 );
......
......@@ -3,7 +3,7 @@
Plugin Name: WP Super Cache
Plugin URI: https://wordpress.org/plugins/wp-super-cache/
Description: Very fast caching plugin for WordPress.
Version: 1.5.7
Version: 1.5.7.1
Author: Automattic
Author URI: https://automattic.com/
License: GPL2+
......@@ -3502,8 +3502,13 @@ function wp_cron_preload_cache() {
set_time_limit( 60 );
if ( $page_on_front != 0 && ( $post_id == $page_on_front || $post_id == $page_for_posts ) )
continue;
clear_post_supercache( $post_id );
$url = get_permalink( $post_id );
if ( wp_cache_is_rejected( $url ) ) {
wp_cache_debug( "wp_cron_preload_cache: skipped $url per rejected strings setting" );
continue;
}
clear_post_supercache( $post_id );
$fp = @fopen( $permalink_counter_msg, 'w' );
if ( $fp ) {
@fwrite( $fp, $count . " " . $url );
......@@ -3979,10 +3984,22 @@ function update_mod_rewrite_rules( $add_rules = true ) {
return true;
}
function wpsc_timestamp_cache_update( $type, $permalink ) {
wp_cache_setting( 'wpsc_last_post_update', time() );
// Delete feeds when the site is updated so that feed files are always fresh
function wpsc_feed_update( $type, $permalink ) {
$wpsc_feed_list = get_option( 'wpsc_feed_list' );
update_option( 'wpsc_feed_list', array() );
if ( is_array( $wpsc_feed_list ) && ! empty( $wpsc_feed_list ) ) {
if ( ! function_exists( 'prune_super_cache' ) )
include_once( 'wp-cache-phase2.php' );
foreach( $wpsc_feed_list as $file ) {
wp_cache_debug( "wpsc_feed_update: deleting feed: $file" );
prune_super_cache( $file, true );
prune_super_cache( dirname( $file ) . '/meta-' . basename( $file ), true );
}
}
}
add_action( 'gc_cache', 'wpsc_timestamp_cache_update', 10, 2 );
add_action( 'gc_cache', 'wpsc_feed_update', 10, 2 );
function wpsc_get_plugin_list() {
$list = do_cacheaction( 'wpsc_filter_list' );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment