diff --git a/CHANGELOG.md b/CHANGELOG.md index 90f3e52a..f12b1474 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ This is an alpha version! The changes listed here are not final. - 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. - WP Super Cache: don't create an output buffer if there's already one active +- WP Super Cache: fixed serving a cached page on POST with late init enabled. - WP Super Cache: fix the output buffer check, and make debug logs pre-formatted. ## [1.11.0] - 2023-11-08 diff --git a/wp-cache-phase1.php b/wp-cache-phase1.php index 91d6e1d1..beb065e2 100644 --- a/wp-cache-phase1.php +++ b/wp-cache-phase1.php @@ -109,6 +109,7 @@ // don't cache in wp-admin if ( wpsc_is_backend() ) { + define( 'DONOTCACHEPAGE', 1 ); return true; } @@ -122,6 +123,7 @@ if ( wpsc_is_caching_user_disabled() ) { wp_cache_debug( 'Caching disabled for logged in users on settings page.' ); + define( 'DONOTCACHEPAGE', 1 ); return true; } @@ -133,8 +135,20 @@ // an init action wpsc plugins can hook on to. do_cacheaction( 'cache_init' ); +if ( ! $cache_enabled ) { + return true; +} + // don't cache or serve cached files for various URLs, including the Customizer. -if ( ! $cache_enabled || ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( $_SERVER['REQUEST_METHOD'], array( 'POST', 'PUT', 'DELETE' ) ) ) || isset( $_GET['customize_changeset_uuid'] ) ) { +if ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( $_SERVER['REQUEST_METHOD'], array( 'POST', 'PUT', 'DELETE' ), true ) ) { + wp_cache_debug( 'Caching disabled for non GET request.' ); + define( 'DONOTCACHEPAGE', 1 ); + return true; +} + +if ( isset( $_GET['customize_changeset_uuid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended + wp_cache_debug( 'Caching disabled for customizer.' ); + define( 'DONOTCACHEPAGE', 1 ); return true; } diff --git a/wp-cache-phase2.php b/wp-cache-phase2.php index ff05d94b..5ede1706 100644 --- a/wp-cache-phase2.php +++ b/wp-cache-phase2.php @@ -390,6 +390,11 @@ function wp_cache_postload() { global $cache_enabled, $wp_super_cache_late_init; global $wp_cache_request_uri; + if ( defined( 'DONOTCACHEPAGE' ) && DONOTCACHEPAGE ) { + wp_cache_debug( 'wp_cache_postload: DONOTCACHEPAGE defined. Not running.' ); + return false; + } + if ( empty( $wp_cache_request_uri ) ) { wp_cache_debug( 'wp_cache_postload: no request uri configured. Not running.' ); return false;