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

No need to delete the "page_on_front" as it's already done #175

Merged
merged 2 commits into from
Feb 2, 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
20 changes: 11 additions & 9 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -1133,21 +1133,19 @@ function wp_cache_post_id_gc( $siteurl, $post_id, $all = 'all' ) {
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( $post_id ) ) );
$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 == 'all' ) {
if ( $all ) {
prune_super_cache( $dir, true, true );
do_action( 'gc_cache', 'prune', $permalink );
@rmdir( $dir );
wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$supercache_home}page/." );
$supercache_home = get_supercache_dir();
prune_super_cache( $supercache_home . 'page/', true );
do_action( 'gc_cache', 'prune', 'page/' );
} else {
wp_cache_debug( "wp_cache_post_id_gc clearing cached index files in $dir.", 4 );
prune_super_cache( $dir, true, true );
do_action( 'gc_cache', 'prune', $permalink );
}
wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$dir}/page/.", 4 );
prune_super_cache( $dir . '/page/', true );
$supercache_home = get_supercache_dir();
wp_cache_debug( "wp_cache_post_id_gc clearing cache in {$supercache_home}/page/.", 4 );
prune_super_cache( $supercache_home . '/page/', true );
do_action( 'gc_cache', 'prune', '/page/' );
}

function wp_cache_post_change( $post_id ) {
Expand Down Expand Up @@ -1182,6 +1180,11 @@ function wp_cache_post_change( $post_id ) {
$all = true;
}

$all_backup = $all;
$all = apply_filters( 'wpsc_delete_related_pages_on_edit', $all ); // return 0 to disable deleting homepage and other pages.
if ( $all != $all_backup )
wp_cache_debug( 'wp_cache_post_change: $all changed by wpsc_delete_related_pages_on_edit filter: ' . intval( $all ) );

if ( $wp_cache_object_cache )
reset_oc_version();

Expand All @@ -1191,7 +1194,7 @@ function wp_cache_post_change( $post_id ) {
$dir = get_supercache_dir();
$siteurl = trailingslashit( strtolower( preg_replace( '/:.*$/', '', str_replace( 'https://', '', str_replace( 'http://', '', get_option( 'home' ) ) ) ) ) );
// make sure the front page has a rebuild file
wp_cache_post_id_gc( $siteurl, $post_id );
wp_cache_post_id_gc( $siteurl, $post_id, $all );
if ( $all == true ) {
wp_cache_debug( "Post change: supercache enabled: deleting cache files in " . $cache_path . 'supercache/' . $siteurl, 4 );
$files_to_check = get_all_supercache_filenames( $dir );
Expand All @@ -1206,7 +1209,6 @@ function wp_cache_post_change( $post_id ) {
if( $all == true && get_option( 'show_on_front' ) == 'page' ) {
wp_cache_debug( "Post change: deleting page_on_front and page_for_posts pages.", 4 );
wp_cache_debug( "Post change: page_on_front " . get_option( 'page_on_front' ), 4 );
wp_cache_post_id_gc( $siteurl, get_option( 'page_on_front' ), 'single' );
$permalink = trailingslashit( str_replace( get_option( 'home' ), '', get_permalink( get_option( 'page_for_posts' ) ) ) );
$files_to_check = get_all_supercache_filenames( $dir . $permalink );
foreach( $files_to_check as $cache_file ) {
Expand Down