Version Description
- Catch fatal errors so they're not cached, improve code that catches unknown page types. (#367)
- Fix caching on older WP installs, and if the plugin is inactive on a blog, but still caching, give feeds a short TTL to ensure they're fresh. (#366)
- When preloading don't delete sub-directories, or child pages, when caching pages. (#363)
- Avoid PHP warnings from the REST API for settings that are not yet defined. (#361)
- Added missing settings to the config file. (#360)
Download this release
Release Info
Developer | donncha |
Plugin | WP Super Cache |
Version | 1.5.5 |
Comparing to | |
See all releases |
Code changes from version 1.5.4 to 1.5.5
- readme.txt +9 -3
- rest/class.wp-super-cache-rest-get-settings.php +5 -1
- wp-cache-config-sample.php +3 -0
- wp-cache-phase1.php +4 -3
- wp-cache-phase2.php +63 -32
- wp-cache.php +11 -2
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.8.1
|
5 |
-
Stable tag: 1.5.
|
6 |
Requires at least: 3.0
|
7 |
|
8 |
A very fast caching engine for WordPress that produces static html files.
|
@@ -53,10 +53,16 @@ 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 |
-
|
57 |
-
|
58 |
|
59 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
= 1.5.4 =
|
61 |
* Fix messages related to creating advanced-cache.php (#355, #354)
|
62 |
* Deleting the plugin doesn't need to delete the cache directory as it's already done on deactivation. (#323)
|
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.5
|
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 |
+
Fix for older versions of WordPress, catch fatal errors before they're cached, preload fixes.
|
|
|
57 |
|
58 |
== Changelog ==
|
59 |
+
= 1.5.5 =
|
60 |
+
* Catch fatal errors so they're not cached, improve code that catches unknown page types. (#367)
|
61 |
+
* Fix caching on older WP installs, and if the plugin is inactive on a blog, but still caching, give feeds a short TTL to ensure they're fresh. (#366)
|
62 |
+
* When preloading don't delete sub-directories, or child pages, when caching pages. (#363)
|
63 |
+
* Avoid PHP warnings from the REST API for settings that are not yet defined. (#361)
|
64 |
+
* Added missing settings to the config file. (#360)
|
65 |
+
|
66 |
= 1.5.4 =
|
67 |
* Fix messages related to creating advanced-cache.php (#355, #354)
|
68 |
* Deleting the plugin doesn't need to delete the cache directory as it's already done on deactivation. (#323)
|
rest/class.wp-super-cache-rest-get-settings.php
CHANGED
@@ -43,7 +43,11 @@ class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
|
|
43 |
|
44 |
} elseif ( isset( $map['global'] ) ) {
|
45 |
$global_var = $map['global'];
|
46 |
-
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
}
|
49 |
|
43 |
|
44 |
} elseif ( isset( $map['global'] ) ) {
|
45 |
$global_var = $map['global'];
|
46 |
+
if ( false == isset( $$global_var ) ) {
|
47 |
+
$settings[ $name ] = false;
|
48 |
+
} else {
|
49 |
+
$settings[ $name ] = $$global_var;
|
50 |
+
}
|
51 |
}
|
52 |
}
|
53 |
|
wp-cache-config-sample.php
CHANGED
@@ -98,4 +98,7 @@ $wp_cache_preload_email_volume = 'none';
|
|
98 |
$wp_cache_mobile_prefixes = '';
|
99 |
$cached_direct_pages = array();
|
100 |
$wpsc_served_header = false;
|
|
|
|
|
|
|
101 |
?>
|
98 |
$wp_cache_mobile_prefixes = '';
|
99 |
$cached_direct_pages = array();
|
100 |
$wpsc_served_header = false;
|
101 |
+
$cache_gc_email_me = 0;
|
102 |
+
$wpsc_save_headers = 0;
|
103 |
+
$cache_schedule_interval = 'daily';
|
104 |
?>
|
wp-cache-phase1.php
CHANGED
@@ -46,6 +46,8 @@ if( is_array( $plugins ) ) {
|
|
46 |
}
|
47 |
}
|
48 |
|
|
|
|
|
49 |
if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) {
|
50 |
wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
|
51 |
return true;
|
@@ -109,8 +111,6 @@ function setup_blog_cache_dir() {
|
|
109 |
@mkdir( $blog_cache_dir . 'meta' );
|
110 |
}
|
111 |
|
112 |
-
$wp_start_time = microtime();
|
113 |
-
|
114 |
function get_wp_cache_key( $url = false ) {
|
115 |
global $wp_cache_request_uri, $wp_cache_gzip_encoding, $WPSC_HTTP_HOST;
|
116 |
if ( ! $url ) {
|
@@ -200,7 +200,8 @@ function wp_cache_serve_cache_file() {
|
|
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 |
wp_cache_debug( "wp_cache_serve_cache_file: feed out of date. deleting cache files: $meta_pathname, $cache_file" );
|
205 |
@unlink( $meta_pathname );
|
206 |
@unlink( $cache_file );
|
46 |
}
|
47 |
}
|
48 |
|
49 |
+
$wp_start_time = microtime();
|
50 |
+
|
51 |
if ( $wp_cache_not_logged_in && wp_cache_get_cookies_values() ) {
|
52 |
wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
|
53 |
return true;
|
111 |
@mkdir( $blog_cache_dir . 'meta' );
|
112 |
}
|
113 |
|
|
|
|
|
114 |
function get_wp_cache_key( $url = false ) {
|
115 |
global $wp_cache_request_uri, $wp_cache_gzip_encoding, $WPSC_HTTP_HOST;
|
116 |
if ( ! $url ) {
|
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 );
|
wp-cache-phase2.php
CHANGED
@@ -32,8 +32,8 @@ function wp_cache_phase2() {
|
|
32 |
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
|
33 |
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);
|
34 |
// No post_id is available
|
35 |
-
add_action('switch_theme', 'wp_cache_no_postid', 99);
|
36 |
-
add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
|
37 |
add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache_on_menu' );
|
38 |
add_action('wp_cache_gc','wp_cache_gc_cron');
|
39 |
add_action( 'clean_post_cache', 'wp_cache_post_edit' );
|
@@ -58,7 +58,7 @@ function wp_cache_phase2() {
|
|
58 |
header('Vary: Accept-Encoding, Cookie');
|
59 |
else
|
60 |
header('Vary: Cookie');
|
61 |
-
ob_start( 'wp_cache_ob_callback' );
|
62 |
wp_cache_debug( 'Created output buffer', 4 );
|
63 |
|
64 |
// restore old supercache file temporarily
|
@@ -289,7 +289,7 @@ function wp_cache_mutex_init() {
|
|
289 |
return true;
|
290 |
|
291 |
if( !is_bool( $use_flock ) ) {
|
292 |
-
if(function_exists('sem_get'))
|
293 |
$use_flock = false;
|
294 |
else
|
295 |
$use_flock = true;
|
@@ -370,12 +370,29 @@ function wp_super_cache_query_vars() {
|
|
370 |
$wp_super_cache_query[ 'is_home' ] = 1;
|
371 |
if ( is_author() )
|
372 |
$wp_super_cache_query[ 'is_author' ] = 1;
|
373 |
-
if ( is_feed() || get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) )
|
374 |
$wp_super_cache_query[ 'is_feed' ] = 1;
|
|
|
|
|
375 |
|
376 |
return $wp_super_cache_query;
|
377 |
}
|
378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
function wp_cache_ob_callback( $buffer ) {
|
380 |
global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_object_cache, $wp_cache_request_uri, $do_rebuild_list, $wpsc_file_mtimes, $wpsc_save_headers, $super_cache_enabled;
|
381 |
$buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
|
@@ -385,13 +402,16 @@ function wp_cache_ob_callback( $buffer ) {
|
|
385 |
// All the things that can stop a page being cached
|
386 |
$cache_this_page = true;
|
387 |
|
388 |
-
if (
|
|
|
|
|
|
|
389 |
$wp_super_cache_query = wp_super_cache_query_vars();
|
390 |
}
|
391 |
|
392 |
-
if ( empty( $wp_super_cache_query ) ) {
|
393 |
$cache_this_page = false;
|
394 |
-
wp_cache_debug( 'wp_cache_ob_callback: wp_super_cache_query is empty. Not caching unknown page type.' );
|
395 |
} elseif ( defined( 'DONOTCACHEPAGE' ) ) {
|
396 |
wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
|
397 |
$cache_this_page = false;
|
@@ -454,9 +474,6 @@ function wp_cache_ob_callback( $buffer ) {
|
|
454 |
if ( isset( $wpsc_save_headers ) && $wpsc_save_headers )
|
455 |
$super_cache_enabled = false; // use standard caching to record headers
|
456 |
|
457 |
-
if ( !isset( $wp_query ) )
|
458 |
-
wp_cache_debug( 'wp_cache_ob_callback: WARNING! $query not defined but the plugin has worked around that problem.', 4 );
|
459 |
-
|
460 |
if ( $cache_this_page ) {
|
461 |
|
462 |
wp_cache_debug( 'Output buffer callback', 4 );
|
@@ -530,7 +547,7 @@ function wp_cache_add_to_buffer( &$buffer, $text ) {
|
|
530 |
$buffer .= "\n<!-- $text -->";
|
531 |
}
|
532 |
|
533 |
-
/*
|
534 |
* If dynamic caching is enabled then run buffer through wpsc_cachedata filter before returning it.
|
535 |
* or we'll return template tags to visitors.
|
536 |
*/
|
@@ -560,7 +577,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
560 |
$new_cache = true;
|
561 |
$wp_cache_meta = array();
|
562 |
|
563 |
-
/* Mode paranoic, check for closing tags
|
564 |
* we avoid caching incomplete files */
|
565 |
if ( $buffer == '' ) {
|
566 |
$new_cache = false;
|
@@ -771,13 +788,13 @@ function wp_cache_get_ob(&$buffer) {
|
|
771 |
wp_cache_debug( "Writing gzipped buffer to wp-cache cache file.", 5 );
|
772 |
fputs($fr, '<?php die(); ?>' . $gzdata);
|
773 |
} elseif ( $cache_enabled && $wp_cache_object_cache ) {
|
774 |
-
wp_cache_set( $oc_key . ".gz", $gzdata, 'supercache', $cache_max_time );
|
775 |
$added_cache = 1;
|
776 |
}
|
777 |
} else { // no compression
|
778 |
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Cookie';
|
779 |
if ( $cache_enabled && $wp_cache_object_cache ) {
|
780 |
-
wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
|
781 |
$added_cache = 1;
|
782 |
} elseif ( $fr ) {
|
783 |
wp_cache_debug( "Writing non-gzipped buffer to wp-cache cache file." );
|
@@ -788,7 +805,7 @@ function wp_cache_get_ob(&$buffer) {
|
|
788 |
wp_cache_debug( "Writing non-gzipped buffer to supercache file." );
|
789 |
wp_cache_add_to_buffer( $buffer, "super cache" );
|
790 |
fputs($fr2, $buffer );
|
791 |
-
}
|
792 |
if ( isset( $gzdata ) && $gz ) {
|
793 |
wp_cache_debug( "Writing gzipped buffer to supercache file." );
|
794 |
fwrite($gz, $gzdata );
|
@@ -874,7 +891,7 @@ function wp_cache_phase2_clean_cache($file_prefix) {
|
|
874 |
if( !wp_cache_writers_entry() )
|
875 |
return false;
|
876 |
wp_cache_debug( "wp_cache_phase2_clean_cache: Cleaning cache in $blog_cache_dir" );
|
877 |
-
if ( $handle = @opendir( $blog_cache_dir ) ) {
|
878 |
while ( false !== ($file = @readdir($handle))) {
|
879 |
if ( strpos( $file, $file_prefix ) !== false ) {
|
880 |
if ( strpos( $file, '.html' ) ) {
|
@@ -940,7 +957,7 @@ function prune_super_cache( $directory, $force = false, $rename = false ) {
|
|
940 |
continue;
|
941 |
$entry = $directory . $entry;
|
942 |
prune_super_cache( $entry, $force, $rename );
|
943 |
-
// If entry is a directory, AND it's not a protected one, AND we're either forcing the delete, OR the file is out of date,
|
944 |
if( is_dir( $entry ) && !in_array( $entry, $protected_directories ) && ( $force || @filemtime( $entry ) + $cache_max_time <= $now ) ) {
|
945 |
// if the directory isn't empty can't delete it
|
946 |
if( $handle = @opendir( $entry ) ) {
|
@@ -1064,9 +1081,9 @@ function wp_cache_phase2_clean_expired( $file_prefix, $force = false ) {
|
|
1064 |
$now = time();
|
1065 |
wp_cache_debug( "Cleaning expired cache files in $blog_cache_dir", 2 );
|
1066 |
$deleted = 0;
|
1067 |
-
if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
|
1068 |
while ( false !== ($file = readdir($handle))) {
|
1069 |
-
if ( preg_match("/^$file_prefix/", $file) &&
|
1070 |
(@filemtime( $blog_cache_dir . $file) + $cache_max_time) <= $now ) {
|
1071 |
@unlink( $blog_cache_dir . $file );
|
1072 |
@unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
|
@@ -1098,6 +1115,17 @@ function wp_cache_shutdown_callback() {
|
|
1098 |
global $wp_cache_request_uri, $wp_cache_key, $wp_cache_object_cache, $cache_enabled, $wp_cache_blog_charset, $wp_cache_not_logged_in;
|
1099 |
global $WPSC_HTTP_HOST, $wp_super_cache_query;
|
1100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1101 |
if ( false == $new_cache ) {
|
1102 |
wp_cache_debug( "wp_cache_shutdown_callback: No cache file created. Returning." );
|
1103 |
return false;
|
@@ -1150,10 +1178,18 @@ function wp_cache_shutdown_callback() {
|
|
1150 |
$value = "application/rss+xml";
|
1151 |
}
|
1152 |
}
|
|
|
|
|
|
|
|
|
1153 |
wp_cache_debug( "wp_cache_shutdown_callback: feed is type: $type - $value" );
|
1154 |
} elseif ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) {
|
1155 |
wp_cache_debug( "wp_cache_shutdown_callback: sitemap detected: text/xml" );
|
1156 |
$value = "text/xml";
|
|
|
|
|
|
|
|
|
1157 |
} else { // not a feed
|
1158 |
$value = get_option( 'html_type' );
|
1159 |
if( $value == '' )
|
@@ -1256,7 +1292,7 @@ function wp_cache_get_postid_from_comment( $comment_id, $status = 'NA' ) {
|
|
1256 |
}
|
1257 |
}
|
1258 |
// We must check it up again due to WP bugs calling two different actions
|
1259 |
-
// for delete, for example both wp_set_comment_status and delete_comment
|
1260 |
// are called when deleting a comment
|
1261 |
if ($postid > 0) {
|
1262 |
wp_cache_debug( "Post $postid changed. Update cache.", 4 );
|
@@ -1343,7 +1379,7 @@ function wp_cache_post_edit($post_id) {
|
|
1343 |
if ( is_object( $post ) == false )
|
1344 |
return $post_id;
|
1345 |
|
1346 |
-
// Some users are inexplicibly seeing this error on scheduled posts.
|
1347 |
// define this constant to disable the post status check.
|
1348 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
1349 |
wp_cache_debug( "wp_cache_post_edit: draft post, not deleting any cache files. status: " . $post->post_status, 4 );
|
@@ -1389,7 +1425,7 @@ function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
|
|
1389 |
do_action( 'gc_cache', 'prune', 'page/' );
|
1390 |
} else {
|
1391 |
wp_cache_debug( "wp_cache_post_id_gc clearing cached index files in $dir.", 4 );
|
1392 |
-
prune_super_cache( $dir, true, true );
|
1393 |
do_action( 'gc_cache', 'prune', $permalink );
|
1394 |
}
|
1395 |
}
|
@@ -1403,7 +1439,7 @@ function wp_cache_post_change( $post_id ) {
|
|
1403 |
return $post_id;
|
1404 |
}
|
1405 |
$post = get_post( $post_id );
|
1406 |
-
// Some users are inexplicibly seeing this error on scheduled posts.
|
1407 |
// define this constant to disable the post status check.
|
1408 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
1409 |
wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
|
@@ -1458,7 +1494,7 @@ function wp_cache_post_change( $post_id ) {
|
|
1458 |
|
1459 |
wp_cache_debug( "wp_cache_post_change: checking {$blog_cache_dir}meta/", 4 );
|
1460 |
$supercache_files_deleted = false;
|
1461 |
-
if ( $handle = @opendir( $blog_cache_dir ) ) {
|
1462 |
while ( false !== ($file = readdir($handle))) {
|
1463 |
if ( strpos( $file, $file_prefix ) !== false ) {
|
1464 |
if ( strpos( $file, '.html' ) ) {
|
@@ -1518,7 +1554,7 @@ function wp_cache_post_id() {
|
|
1518 |
// We try hard all options. More frequent first.
|
1519 |
if ($post_ID > 0 ) return $post_ID;
|
1520 |
if ($comment_post_ID > 0 ) return $comment_post_ID;
|
1521 |
-
if (
|
1522 |
if (isset( $_GET[ 'p' ] ) && $_GET['p'] > 0) return $_GET['p'];
|
1523 |
if (isset( $_POST[ 'p' ] ) && $_POST['p'] > 0) return $_POST['p'];
|
1524 |
return 0;
|
@@ -1560,7 +1596,7 @@ function wp_cache_gc_cron() {
|
|
1560 |
return false;
|
1561 |
}
|
1562 |
|
1563 |
-
update_option( 'wpsupercache_gc_time', time() );
|
1564 |
wp_cache_debug( "wp_cache_gc_cron: Set GC Flag. ($gc_flag)", 5 );
|
1565 |
$fp = @fopen( $gc_flag, 'w' );
|
1566 |
@fclose( $fp );
|
@@ -1642,9 +1678,4 @@ function wp_cache_gc_watcher() {
|
|
1642 |
}
|
1643 |
}
|
1644 |
|
1645 |
-
function wpsc_timestamp_cache_update( $type, $permalink ) {
|
1646 |
-
wp_cache_setting( 'wpsc_last_post_update', time() );
|
1647 |
-
}
|
1648 |
-
add_action( 'gc_cache', 'wpsc_timestamp_cache_update', 10, 2 );
|
1649 |
-
|
1650 |
?>
|
32 |
add_action('edit_comment', 'wp_cache_get_postid_from_comment', 99);
|
33 |
add_action('wp_set_comment_status', 'wp_cache_get_postid_from_comment', 99, 2);
|
34 |
// No post_id is available
|
35 |
+
add_action('switch_theme', 'wp_cache_no_postid', 99);
|
36 |
+
add_action('edit_user_profile_update', 'wp_cache_no_postid', 99);
|
37 |
add_action( 'wp_update_nav_menu', 'wp_cache_clear_cache_on_menu' );
|
38 |
add_action('wp_cache_gc','wp_cache_gc_cron');
|
39 |
add_action( 'clean_post_cache', 'wp_cache_post_edit' );
|
58 |
header('Vary: Accept-Encoding, Cookie');
|
59 |
else
|
60 |
header('Vary: Cookie');
|
61 |
+
ob_start( 'wp_cache_ob_callback' );
|
62 |
wp_cache_debug( 'Created output buffer', 4 );
|
63 |
|
64 |
// restore old supercache file temporarily
|
289 |
return true;
|
290 |
|
291 |
if( !is_bool( $use_flock ) ) {
|
292 |
+
if(function_exists('sem_get'))
|
293 |
$use_flock = false;
|
294 |
else
|
295 |
$use_flock = true;
|
370 |
$wp_super_cache_query[ 'is_home' ] = 1;
|
371 |
if ( is_author() )
|
372 |
$wp_super_cache_query[ 'is_author' ] = 1;
|
373 |
+
if ( is_feed() || ( method_exists( $GLOBALS['wp_query'], 'get') && ( get_query_var( 'sitemap' ) || get_query_var( 'xsl' ) || get_query_var( 'xml_sitemap' ) ) ) )
|
374 |
$wp_super_cache_query[ 'is_feed' ] = 1;
|
375 |
+
if ( is_404() )
|
376 |
+
$wp_super_cache_query = array( 'is_404' => 1 );
|
377 |
|
378 |
return $wp_super_cache_query;
|
379 |
}
|
380 |
|
381 |
+
function wpsc_is_fatal_error() {
|
382 |
+
global $wp_super_cache_query;
|
383 |
+
|
384 |
+
if ( null === ( $error = error_get_last() ) ) {
|
385 |
+
return false;
|
386 |
+
}
|
387 |
+
|
388 |
+
if ( $error['type'] & ( E_ERROR | E_CORE_ERROR | E_PARSE | E_COMPILE_ERROR | E_USER_ERROR ) ) {
|
389 |
+
$wp_super_cache_query[ 'is_fatal_error' ] = 1;
|
390 |
+
return true;
|
391 |
+
}
|
392 |
+
|
393 |
+
return false;
|
394 |
+
}
|
395 |
+
|
396 |
function wp_cache_ob_callback( $buffer ) {
|
397 |
global $wp_cache_pages, $wp_query, $wp_super_cache_query, $cache_acceptable_files, $wp_cache_no_cache_for_get, $wp_cache_object_cache, $wp_cache_request_uri, $do_rebuild_list, $wpsc_file_mtimes, $wpsc_save_headers, $super_cache_enabled;
|
398 |
$buffer = apply_filters( 'wp_cache_ob_callback_filter', $buffer );
|
402 |
// All the things that can stop a page being cached
|
403 |
$cache_this_page = true;
|
404 |
|
405 |
+
if ( wpsc_is_fatal_error() ) {
|
406 |
+
$cache_this_page = false;
|
407 |
+
wp_cache_debug( 'wp_cache_ob_callback: PHP Fatal error occurred. Not caching incomplete page.' );
|
408 |
+
} elseif ( empty( $wp_super_cache_query ) && !empty( $buffer ) && is_object( $wp_query ) ) {
|
409 |
$wp_super_cache_query = wp_super_cache_query_vars();
|
410 |
}
|
411 |
|
412 |
+
if ( empty( $wp_super_cache_query ) && function_exists( 'apply_filter' ) && apply_filter( 'wpsc_only_cache_known_pages', 1 ) ) {
|
413 |
$cache_this_page = false;
|
414 |
+
wp_cache_debug( 'wp_cache_ob_callback: wp_super_cache_query is empty. Not caching unknown page type. Return 0 to the wpsc_only_cache_known_pages filter to cache this page.' );
|
415 |
} elseif ( defined( 'DONOTCACHEPAGE' ) ) {
|
416 |
wp_cache_debug( 'DONOTCACHEPAGE defined. Caching disabled.', 2 );
|
417 |
$cache_this_page = false;
|
474 |
if ( isset( $wpsc_save_headers ) && $wpsc_save_headers )
|
475 |
$super_cache_enabled = false; // use standard caching to record headers
|
476 |
|
|
|
|
|
|
|
477 |
if ( $cache_this_page ) {
|
478 |
|
479 |
wp_cache_debug( 'Output buffer callback', 4 );
|
547 |
$buffer .= "\n<!-- $text -->";
|
548 |
}
|
549 |
|
550 |
+
/*
|
551 |
* If dynamic caching is enabled then run buffer through wpsc_cachedata filter before returning it.
|
552 |
* or we'll return template tags to visitors.
|
553 |
*/
|
577 |
$new_cache = true;
|
578 |
$wp_cache_meta = array();
|
579 |
|
580 |
+
/* Mode paranoic, check for closing tags
|
581 |
* we avoid caching incomplete files */
|
582 |
if ( $buffer == '' ) {
|
583 |
$new_cache = false;
|
788 |
wp_cache_debug( "Writing gzipped buffer to wp-cache cache file.", 5 );
|
789 |
fputs($fr, '<?php die(); ?>' . $gzdata);
|
790 |
} elseif ( $cache_enabled && $wp_cache_object_cache ) {
|
791 |
+
wp_cache_set( $oc_key . ".gz", $gzdata, 'supercache', $cache_max_time );
|
792 |
$added_cache = 1;
|
793 |
}
|
794 |
} else { // no compression
|
795 |
$wp_cache_meta[ 'headers' ][ 'Vary' ] = 'Vary: Cookie';
|
796 |
if ( $cache_enabled && $wp_cache_object_cache ) {
|
797 |
+
wp_cache_set( $oc_key, $buffer, 'supercache', $cache_max_time );
|
798 |
$added_cache = 1;
|
799 |
} elseif ( $fr ) {
|
800 |
wp_cache_debug( "Writing non-gzipped buffer to wp-cache cache file." );
|
805 |
wp_cache_debug( "Writing non-gzipped buffer to supercache file." );
|
806 |
wp_cache_add_to_buffer( $buffer, "super cache" );
|
807 |
fputs($fr2, $buffer );
|
808 |
+
}
|
809 |
if ( isset( $gzdata ) && $gz ) {
|
810 |
wp_cache_debug( "Writing gzipped buffer to supercache file." );
|
811 |
fwrite($gz, $gzdata );
|
891 |
if( !wp_cache_writers_entry() )
|
892 |
return false;
|
893 |
wp_cache_debug( "wp_cache_phase2_clean_cache: Cleaning cache in $blog_cache_dir" );
|
894 |
+
if ( $handle = @opendir( $blog_cache_dir ) ) {
|
895 |
while ( false !== ($file = @readdir($handle))) {
|
896 |
if ( strpos( $file, $file_prefix ) !== false ) {
|
897 |
if ( strpos( $file, '.html' ) ) {
|
957 |
continue;
|
958 |
$entry = $directory . $entry;
|
959 |
prune_super_cache( $entry, $force, $rename );
|
960 |
+
// If entry is a directory, AND it's not a protected one, AND we're either forcing the delete, OR the file is out of date,
|
961 |
if( is_dir( $entry ) && !in_array( $entry, $protected_directories ) && ( $force || @filemtime( $entry ) + $cache_max_time <= $now ) ) {
|
962 |
// if the directory isn't empty can't delete it
|
963 |
if( $handle = @opendir( $entry ) ) {
|
1081 |
$now = time();
|
1082 |
wp_cache_debug( "Cleaning expired cache files in $blog_cache_dir", 2 );
|
1083 |
$deleted = 0;
|
1084 |
+
if ( ( $handle = @opendir( $blog_cache_dir ) ) ) {
|
1085 |
while ( false !== ($file = readdir($handle))) {
|
1086 |
+
if ( preg_match("/^$file_prefix/", $file) &&
|
1087 |
(@filemtime( $blog_cache_dir . $file) + $cache_max_time) <= $now ) {
|
1088 |
@unlink( $blog_cache_dir . $file );
|
1089 |
@unlink( $blog_cache_dir . 'meta/' . str_replace( '.html', '.meta', $file ) );
|
1115 |
global $wp_cache_request_uri, $wp_cache_key, $wp_cache_object_cache, $cache_enabled, $wp_cache_blog_charset, $wp_cache_not_logged_in;
|
1116 |
global $WPSC_HTTP_HOST, $wp_super_cache_query;
|
1117 |
|
1118 |
+
if ( ! function_exists( 'wpsc_init' ) ) {
|
1119 |
+
/*
|
1120 |
+
* If a server has multiple networks the plugin may not have been activated
|
1121 |
+
* on all of them. Give feeds on those blogs a short TTL.
|
1122 |
+
* ref: https://wordpress.org/support/topic/fatal-error-while-updating-post-or-publishing-new-one/
|
1123 |
+
*/
|
1124 |
+
$wpsc_feed_ttl = 1;
|
1125 |
+
wp_cache_debug( "wp_cache_shutdown_callback: Plugin not loaded. Setting feed ttl to 60 seconds." );
|
1126 |
+
}
|
1127 |
+
|
1128 |
+
|
1129 |
if ( false == $new_cache ) {
|
1130 |
wp_cache_debug( "wp_cache_shutdown_callback: No cache file created. Returning." );
|
1131 |
return false;
|
1178 |
$value = "application/rss+xml";
|
1179 |
}
|
1180 |
}
|
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' ) ) {
|
1187 |
wp_cache_debug( "wp_cache_shutdown_callback: sitemap detected: text/xml" );
|
1188 |
$value = "text/xml";
|
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' );
|
1195 |
if( $value == '' )
|
1292 |
}
|
1293 |
}
|
1294 |
// We must check it up again due to WP bugs calling two different actions
|
1295 |
+
// for delete, for example both wp_set_comment_status and delete_comment
|
1296 |
// are called when deleting a comment
|
1297 |
if ($postid > 0) {
|
1298 |
wp_cache_debug( "Post $postid changed. Update cache.", 4 );
|
1379 |
if ( is_object( $post ) == false )
|
1380 |
return $post_id;
|
1381 |
|
1382 |
+
// Some users are inexplicibly seeing this error on scheduled posts.
|
1383 |
// define this constant to disable the post status check.
|
1384 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
1385 |
wp_cache_debug( "wp_cache_post_edit: draft post, not deleting any cache files. status: " . $post->post_status, 4 );
|
1425 |
do_action( 'gc_cache', 'prune', 'page/' );
|
1426 |
} else {
|
1427 |
wp_cache_debug( "wp_cache_post_id_gc clearing cached index files in $dir.", 4 );
|
1428 |
+
prune_super_cache( $dir, true, true );
|
1429 |
do_action( 'gc_cache', 'prune', $permalink );
|
1430 |
}
|
1431 |
}
|
1439 |
return $post_id;
|
1440 |
}
|
1441 |
$post = get_post( $post_id );
|
1442 |
+
// Some users are inexplicibly seeing this error on scheduled posts.
|
1443 |
// define this constant to disable the post status check.
|
1444 |
if ( false == defined( 'WPSCFORCEUPDATE' ) && is_object( $post ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
|
1445 |
wp_cache_debug( "wp_cache_post_change: draft post, not deleting any cache files.", 4 );
|
1494 |
|
1495 |
wp_cache_debug( "wp_cache_post_change: checking {$blog_cache_dir}meta/", 4 );
|
1496 |
$supercache_files_deleted = false;
|
1497 |
+
if ( $handle = @opendir( $blog_cache_dir ) ) {
|
1498 |
while ( false !== ($file = readdir($handle))) {
|
1499 |
if ( strpos( $file, $file_prefix ) !== false ) {
|
1500 |
if ( strpos( $file, '.html' ) ) {
|
1554 |
// We try hard all options. More frequent first.
|
1555 |
if ($post_ID > 0 ) return $post_ID;
|
1556 |
if ($comment_post_ID > 0 ) return $comment_post_ID;
|
1557 |
+
if (is_singular() && !empty($posts)) return $posts[0]->ID;
|
1558 |
if (isset( $_GET[ 'p' ] ) && $_GET['p'] > 0) return $_GET['p'];
|
1559 |
if (isset( $_POST[ 'p' ] ) && $_POST['p'] > 0) return $_POST['p'];
|
1560 |
return 0;
|
1596 |
return false;
|
1597 |
}
|
1598 |
|
1599 |
+
update_option( 'wpsupercache_gc_time', time() );
|
1600 |
wp_cache_debug( "wp_cache_gc_cron: Set GC Flag. ($gc_flag)", 5 );
|
1601 |
$fp = @fopen( $gc_flag, 'w' );
|
1602 |
@fclose( $fp );
|
1678 |
}
|
1679 |
}
|
1680 |
|
|
|
|
|
|
|
|
|
|
|
1681 |
?>
|
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 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
@@ -3346,7 +3346,11 @@ function clear_post_supercache( $post_id ) {
|
|
3346 |
include_once( 'wp-cache-phase2.php' );
|
3347 |
|
3348 |
wp_cache_debug( "clear_post_supercache: deleting files in $dir", 2 );
|
3349 |
-
|
|
|
|
|
|
|
|
|
3350 |
}
|
3351 |
|
3352 |
function wp_cron_preload_cache() {
|
@@ -3958,3 +3962,8 @@ function update_mod_rewrite_rules( $add_rules = true ) {
|
|
3958 |
|
3959 |
return true;
|
3960 |
}
|
|
|
|
|
|
|
|
|
|
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.5
|
7 |
Author: Automattic
|
8 |
Author URI: https://automattic.com/
|
9 |
License: GPL2+
|
3346 |
include_once( 'wp-cache-phase2.php' );
|
3347 |
|
3348 |
wp_cache_debug( "clear_post_supercache: deleting files in $dir", 2 );
|
3349 |
+
if ( get_post_type( $post_id ) != 'page' ) { // don't delete child pages if they exist
|
3350 |
+
prune_super_cache( $dir, true );
|
3351 |
+
} else {
|
3352 |
+
wpsc_delete_files( $dir );
|
3353 |
+
}
|
3354 |
}
|
3355 |
|
3356 |
function wp_cron_preload_cache() {
|
3962 |
|
3963 |
return true;
|
3964 |
}
|
3965 |
+
|
3966 |
+
function wpsc_timestamp_cache_update( $type, $permalink ) {
|
3967 |
+
wp_cache_setting( 'wpsc_last_post_update', time() );
|
3968 |
+
}
|
3969 |
+
add_action( 'gc_cache', 'wpsc_timestamp_cache_update', 10, 2 );
|