From cd729d6d83baa9494a8a513f58f6b3828ba29dc1 Mon Sep 17 00:00:00 2001 From: Damian Taggart <4309872+attackant@users.noreply.github.com> Date: Mon, 11 Mar 2024 14:52:47 -0600 Subject: [PATCH] Update HTTP header name in wp-404-caching plugin The HTTP header name 'X-WP_404_Caching-404-Cache' has been updated to 'X-WP-404-Cache' in class-full-page-cache-404 and all its instances within the project. Similarly, the unit tests have been updated to reflect these changes ensuring consistency in the caching system. --- src/features/class-full-page-cache-404.php | 8 ++++---- tests/Feature/FullPageCache404Test.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/features/class-full-page-cache-404.php b/src/features/class-full-page-cache-404.php index aa17c34b..53b191c7 100644 --- a/src/features/class-full-page-cache-404.php +++ b/src/features/class-full-page-cache-404.php @@ -164,7 +164,7 @@ public static function get_cached_response_with_headers(): string { } /** - * Send X-WP_404_Caching HTTP Header. + * Send X-WP-404-Cache HTTP Header. * * @param string $type HIT or MISS. * @param bool $stale Whether the stale cache is in use. Default false. @@ -176,11 +176,11 @@ public static function send_header( string $type, bool $stale = false ): void { } if ( ! $stale && 'HIT' === $type ) { - header( 'X-WP_404_Caching-404-Cache: HIT' ); + header( 'X-WP-404-Cache: HIT' ); } elseif ( $stale && 'HIT' === $type ) { - header( 'X-WP_404_Caching-404-Cache: HIT (stale)' ); + header( 'X-WP-404-Cache: HIT (stale)' ); } elseif ( 'MISS' === $type ) { - header( 'X-WP_404_Caching-404-Cache: MISS' ); + header( 'X-WP-404-Cache: MISS' ); } } diff --git a/tests/Feature/FullPageCache404Test.php b/tests/Feature/FullPageCache404Test.php index 1c52e2aa..602aa4b5 100644 --- a/tests/Feature/FullPageCache404Test.php +++ b/tests/Feature/FullPageCache404Test.php @@ -22,7 +22,7 @@ * * @link https://mantle.alley.com/testing/test-framework.html */ -class Test_Full_Page_Cache_404 extends TestCase { +final class FullPageCache404Test extends TestCase { use Refresh_Database; use Admin_Screen; @@ -215,7 +215,7 @@ public function test_full_page_cache_not_returned_for_non_404(): void { $post_id = self::factory()->post->create( [ 'post_title' => 'Hello World' ] ); $response = $this->get( get_the_permalink( $post_id ) ); $response->assertStatus( 200 ); - $response->assertHeaderMissing( 'X-Alleyvate-404-Cache' ); + $response->assertHeaderMissing( 'X-WP-404-Cache' ); $response->assertSee( 'Hello World' ); $this->assertFalse(