Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a CPT has no rewrite rule then don't clear the cache. #420

Merged
merged 1 commit into from
Oct 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1437,9 +1437,13 @@ function wp_cache_post_id_gc( $post_id, $all = 'all' ) {

$post_id = intval( $post_id );
if( $post_id == 0 )
return;
return true;

$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( $post_id ) ) );
if ( false !== strpos( $permalink, '?' ) ) {
wp_cache_debug( 'wp_cache_post_id_gc: NOT CLEARING CACHE. Permalink has a "?". ' . $permalink );
return false;
}
$dir = get_current_url_supercache_dir( $post_id );
wp_cache_debug( "wp_cache_post_id_gc post_id: $post_id " . get_permalink( $post_id ) . " clearing cache in $dir.", 4 );
if ( $all ) {
Expand All @@ -1455,6 +1459,7 @@ function wp_cache_post_id_gc( $post_id, $all = 'all' ) {
prune_super_cache( $dir, true, true );
do_action( 'gc_cache', 'prune', $permalink );
}
return true;
}

function wp_cache_post_change( $post_id ) {
Expand Down Expand Up @@ -1500,7 +1505,11 @@ function wp_cache_post_change( $post_id ) {
// Delete supercache files whenever a post change event occurs, even if supercache is currently disabled.
$dir = get_supercache_dir();
// make sure the front page has a rebuild file
wp_cache_post_id_gc( $post_id, $all );
if ( false == wp_cache_post_id_gc( $post_id, $all ) ) {
wp_cache_debug( "wp_cache_post_change: not deleting any cache files as GC of post returned false" );
wp_cache_writers_exit();
return false;
}
if ( $all == true ) {
wp_cache_debug( "Post change: supercache enabled: deleting cache files in " . $dir );
wpsc_rebuild_files( $dir );
Expand Down