Skip to content

Commit

Permalink
WP Super Cache: The wp_super_cache_clear_post_cache filter must stop …
Browse files Browse the repository at this point in the history
…all edits (#36069)

* Need to check this filter in more places.

Yes, it should be a single function, but it would still be 3 lines of
code..

* changelog

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/8111778103
  • Loading branch information
dilirity authored and matticbot committed Mar 1, 2024
1 parent 5af624f commit 8ac0c0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This is an alpha version! The changes listed here are not final.
### Fixed
- Supercache: add "days" to "Next preload scheduled" message.
- Super Cache: with rebuild enabled, apply that to subdirectories instead of deleting them.
- WP Super Cache - fix the wp_super_cache_clear_post_cache so the homepage cache isn't deleted too.
- WP Super Cache: bail if the request uri isn't set. It means the plugin isn't configured yet.

## [1.11.0] - 2023-11-08
Expand Down
10 changes: 10 additions & 0 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -3132,6 +3132,11 @@ function wpsc_post_transition( $new_status, $old_status, $post ) {
return;
}

// Allow plugins to reject cache clears for specific posts.
if ( ! apply_filters( 'wp_super_cache_clear_post_cache', true, $post ) ) {
return;
}

if ( ( $old_status === 'private' || $old_status === 'publish' ) && $new_status !== 'publish' ) { // post unpublished
if ( ! function_exists( 'get_sample_permalink' ) ) {
require_once ABSPATH . 'wp-admin/includes/post.php';
Expand Down Expand Up @@ -3240,6 +3245,11 @@ function wp_cache_post_change( $post_id ) {
return $post_id;
}

// Allow plugins to reject cache clears for specific posts.
if ( ! apply_filters( 'wp_super_cache_clear_post_cache', true, $post ) ) {
return $post_id;
}

// Some users are inexplicibly seeing this error on scheduled posts.
// define this constant to disable the post status check.
if ( ! defined( 'WPSCFORCEUPDATE' ) && ! in_array( get_post_status( $post ), array( 'publish', 'private' ), true ) ) {
Expand Down

0 comments on commit 8ac0c0f

Please sign in to comment.