From 6e094794f92b77080f941b1473b19f89fbf3f1c9 Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 10:14:25 +1300 Subject: [PATCH 1/8] use option instead of transient and more aggressive on cache busting --- .../stats-admin/src/class-odyssey-assets.php | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/projects/packages/stats-admin/src/class-odyssey-assets.php b/projects/packages/stats-admin/src/class-odyssey-assets.php index 8117e650ae5fa..0ddd983c56466 100644 --- a/projects/packages/stats-admin/src/class-odyssey-assets.php +++ b/projects/packages/stats-admin/src/class-odyssey-assets.php @@ -77,34 +77,53 @@ public function load_admin_scripts( $asset_handle, $asset_name, $options = array * Development mode doesn't need this, as it's handled by `Assets` class. */ protected function get_cdn_asset_cache_buster() { + $now = time(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['force_refresh'] ) ) { - set_transient( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, floor( microtime( true ) * 1000 ), 15 * MINUTE_IN_SECONDS ); + update_option( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, $this->get_cache_buster_option_value( $now ), false ); } // Use cached cache buster in production. - $remote_asset_version = get_transient( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY ); + $remote_asset_version = get_option( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY ); if ( ! empty( $remote_asset_version ) ) { - return $remote_asset_version; + $remote_asset_version = json_decode( $remote_asset_version, true ); + if ( ! empty( $remote_asset_version['cache_buster'] ) && $remote_asset_version['cached_at'] > $now - MINUTE_IN_SECONDS * 15 ) { + return $remote_asset_version['cache_buster']; + } } // If no cached cache buster, we fetch it from CDN and set to transient. - $response = wp_remote_get( sprintf( self::ODYSSEY_CDN_URL, self::ODYSSEY_STATS_VERSION, 'build_meta.json?t=' . time() ), array( 'timeout' => 5 ) ); + $response = wp_remote_get( sprintf( self::ODYSSEY_CDN_URL, self::ODYSSEY_STATS_VERSION, 'build_meta.json?t=' . $now ), array( 'timeout' => 5 ) ); if ( is_wp_error( $response ) ) { - // fallback to the package version. - return Main::VERSION; + // fallback to current timestamp. + return $now; } $build_meta = json_decode( wp_remote_retrieve_body( $response ), true ); if ( ! empty( $build_meta['cache_buster'] ) ) { // Cache the cache buster for 15 mins. - set_transient( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, $build_meta['cache_buster'], 15 * MINUTE_IN_SECONDS ); + update_option( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, $this->get_cache_buster_option_value( $build_meta['cache_buster'] ), false ); return $build_meta['cache_buster']; } - // fallback to the package version. - return Main::VERSION; + // fallback to current timestamp. + return $now; + } + + /** + * Get the cache buster option value. + * + * @param string $cache_buster The cache buster. + * @return string|false + */ + protected function get_cache_buster_option_value( $cache_buster ) { + return wp_json_encode( + array( + 'cache_buster' => (string) $cache_buster, + 'cached_at' => time(), + ) + ); } } From 4e4d9f0850e01dc93ef049610f96b8a9a2a88716 Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 10:15:34 +1300 Subject: [PATCH 2/8] changelog --- .../changelog/update-use-option-value-instead-of-transient | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/stats-admin/changelog/update-use-option-value-instead-of-transient diff --git a/projects/packages/stats-admin/changelog/update-use-option-value-instead-of-transient b/projects/packages/stats-admin/changelog/update-use-option-value-instead-of-transient new file mode 100644 index 0000000000000..6e6660e388644 --- /dev/null +++ b/projects/packages/stats-admin/changelog/update-use-option-value-instead-of-transient @@ -0,0 +1,4 @@ +Significance: patch +Type: changed + +Odyssey Stats cache busting: use optioin instead of transient From cb9f99d62bc31f608b0537b2df9e8511b0172e23 Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 11:26:14 +1300 Subject: [PATCH 3/8] added tests --- .../stats-admin/src/class-odyssey-assets.php | 16 +-- .../stats-admin/tests/php/class-test-case.php | 2 + .../tests/php/test-odyssey-assets.php | 101 +++++++++++++++++- 3 files changed, 111 insertions(+), 8 deletions(-) diff --git a/projects/packages/stats-admin/src/class-odyssey-assets.php b/projects/packages/stats-admin/src/class-odyssey-assets.php index 0ddd983c56466..79d9e5528145c 100644 --- a/projects/packages/stats-admin/src/class-odyssey-assets.php +++ b/projects/packages/stats-admin/src/class-odyssey-assets.php @@ -75,12 +75,14 @@ public function load_admin_scripts( $asset_handle, $asset_name, $options = array /** * Returns cache buster string for assets. * Development mode doesn't need this, as it's handled by `Assets` class. + * + * @return string */ protected function get_cdn_asset_cache_buster() { - $now = time(); + $now_in_ms = floor( microtime( true ) * 1000 ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['force_refresh'] ) ) { - update_option( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, $this->get_cache_buster_option_value( $now ), false ); + update_option( self::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, $this->get_cache_buster_option_value( $now_in_ms ), false ); } // Use cached cache buster in production. @@ -88,17 +90,17 @@ protected function get_cdn_asset_cache_buster() { if ( ! empty( $remote_asset_version ) ) { $remote_asset_version = json_decode( $remote_asset_version, true ); - if ( ! empty( $remote_asset_version['cache_buster'] ) && $remote_asset_version['cached_at'] > $now - MINUTE_IN_SECONDS * 15 ) { + if ( ! empty( $remote_asset_version['cache_buster'] ) && $remote_asset_version['cached_at'] > $now_in_ms - MINUTE_IN_SECONDS * 1000 * 15 ) { return $remote_asset_version['cache_buster']; } } // If no cached cache buster, we fetch it from CDN and set to transient. - $response = wp_remote_get( sprintf( self::ODYSSEY_CDN_URL, self::ODYSSEY_STATS_VERSION, 'build_meta.json?t=' . $now ), array( 'timeout' => 5 ) ); + $response = wp_remote_get( sprintf( self::ODYSSEY_CDN_URL, self::ODYSSEY_STATS_VERSION, 'build_meta.json?t=' . $now_in_ms ), array( 'timeout' => 5 ) ); if ( is_wp_error( $response ) ) { // fallback to current timestamp. - return $now; + return (string) $now_in_ms; } $build_meta = json_decode( wp_remote_retrieve_body( $response ), true ); @@ -109,7 +111,7 @@ protected function get_cdn_asset_cache_buster() { } // fallback to current timestamp. - return $now; + return (string) $now_in_ms; } /** @@ -122,7 +124,7 @@ protected function get_cache_buster_option_value( $cache_buster ) { return wp_json_encode( array( 'cache_buster' => (string) $cache_buster, - 'cached_at' => time(), + 'cached_at' => floor( microtime( true ) * 1000 ), // milliseconds. ) ); } diff --git a/projects/packages/stats-admin/tests/php/class-test-case.php b/projects/packages/stats-admin/tests/php/class-test-case.php index e6b919b204a4f..0d21e264cf842 100644 --- a/projects/packages/stats-admin/tests/php/class-test-case.php +++ b/projects/packages/stats-admin/tests/php/class-test-case.php @@ -60,6 +60,7 @@ public function set_up() { add_filter( 'jetpack_options', array( $this, 'mock_jetpack_site_connection_options' ), 10, 2 ); add_filter( 'pre_http_request', array( $this, 'plan_http_response_fixture' ), 10, 3 ); + delete_option( Odyssey_Assets::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY ); } /** @@ -76,6 +77,7 @@ public function tear_down() { remove_filter( 'pre_http_request', array( $this, 'plan_http_response_fixture' ) ); remove_filter( 'jetpack_options', array( $this, 'mock_jetpack_site_connection_options' ) ); + delete_option( Odyssey_Assets::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY ); } /** diff --git a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php index f99eca36ad1fe..24c2fdade7a8c 100644 --- a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php +++ b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php @@ -2,6 +2,7 @@ namespace Automattic\Jetpack\Stats_Admin; use Automattic\Jetpack\Stats_Admin\Test_Case as Stats_Test_Case; +use WP_Error; /** * Unit tests for the Odyssey_Assets class. @@ -9,13 +10,111 @@ * @package automattic/jetpack-stats-admin */ class Test_Odyssey_Assets extends Stats_Test_Case { + /** * Test remote cache buster. */ public function test_get_cdn_asset_cache_buster() { + list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); + $this->assertEquals( 'calypso-4917-8664-g72a154d63a', $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) ); + } + + /** + * Test remote cache buster breaking. + */ + public function test_get_cdn_asset_cache_buster_force_refresh() { + list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); + add_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15, 3 ); + $this->assertEquals( time(), floor( $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) / 1000 ) ); + remove_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15 ); + } + + /** + * Test already cached cache buster. + */ + public function test_get_cdn_asset_cache_buster_already_cached() { + list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); + update_option( + Odyssey_Assets::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, + wp_json_encode( + array( + 'cache_buster' => 'calypso-4917-8664-123456', + 'cached_at' => floor( microtime( true ) * 1000 ), // milliseconds. + ) + ), + false + ); + $this->assertEquals( 'calypso-4917-8664-123456', $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) ); + } + + /** + * Test already cached cache buster expired. + */ + public function test_get_cdn_asset_cache_buster_already_cached_expired() { + update_option( + Odyssey_Assets::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, + wp_json_encode( + array( + 'cache_buster' => 'calypso-4917-8664-123456', + 'cached_at' => floor( microtime( true ) * 1000 - MINUTE_IN_SECONDS * 1000 * 20 ), // milliseconds. + ) + ), + false + ); + list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); + $this->assertEquals( 'calypso-4917-8664-g72a154d63a', $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) ); + } + + /** + * Test already cached cache buster expired and failed to fetch new one. + */ + public function test_get_cdn_asset_cache_buster_failed_to_fetch() { + list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); + add_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15, 3 ); + update_option( + Odyssey_Assets::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, + wp_json_encode( + array( + 'cache_buster' => 'calypso-4917-8664-123456', + 'cached_at' => floor( microtime( true ) * 1000 - MINUTE_IN_SECONDS * 1000 * 20 ), // milliseconds. + ) + ), + false + ); + $this->assertEquals( time(), floor( $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) / 1000 ) ); + remove_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15 ); + } + + /** + * Test force refresh cache buster. + */ + public function test_get_cdn_asset_cache_buster_force_refresh_expired() { + list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); + $_GET['force_refresh'] = 1; + $this->assertEquals( time(), floor( $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) / 1000 ) ); + } + + /** + * Test remote cache buster. + * + * @param mixed $response The response array . + * @param mixed $parsed_args The parsed args . + * @param mixed $url The URL . + * @return array | void + */ + public function break_cdn_cache_buster_request( $response, $parsed_args, $url ) { + if ( strpos( $url, '/build_meta.json' ) !== false ) { + return new WP_Error( 500, 'Internal Server Error' ); + } + } + + /** + * Get CDN asset cache buster. + */ + protected function get_cdn_asset_cache_buster_callable() { $odyssey_assets = new Odyssey_Assets(); $get_cdn_asset_cache_buster = new \ReflectionMethod( $odyssey_assets, 'get_cdn_asset_cache_buster' ); $get_cdn_asset_cache_buster->setAccessible( true ); - $this->assertEquals( 'calypso-4917-8664-g72a154d63a', $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) ); + return array( $get_cdn_asset_cache_buster, $odyssey_assets ); } } From 70bc448405ab634e3e1bd54bdb3c730725748d94 Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 11:32:06 +1300 Subject: [PATCH 4/8] add comment --- projects/packages/stats-admin/src/class-odyssey-assets.php | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/packages/stats-admin/src/class-odyssey-assets.php b/projects/packages/stats-admin/src/class-odyssey-assets.php index 79d9e5528145c..8973b9d3661eb 100644 --- a/projects/packages/stats-admin/src/class-odyssey-assets.php +++ b/projects/packages/stats-admin/src/class-odyssey-assets.php @@ -90,6 +90,7 @@ protected function get_cdn_asset_cache_buster() { if ( ! empty( $remote_asset_version ) ) { $remote_asset_version = json_decode( $remote_asset_version, true ); + // If cache buster is cached and not expired (valid in 15 min), return it. if ( ! empty( $remote_asset_version['cache_buster'] ) && $remote_asset_version['cached_at'] > $now_in_ms - MINUTE_IN_SECONDS * 1000 * 15 ) { return $remote_asset_version['cache_buster']; } From 22d46ea2f86b858c619704b04ffa815747633cd5 Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 14:19:24 +1300 Subject: [PATCH 5/8] fix type comment --- .../packages/stats-admin/src/class-odyssey-assets.php | 2 +- .../stats-admin/tests/php/test-odyssey-assets.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/projects/packages/stats-admin/src/class-odyssey-assets.php b/projects/packages/stats-admin/src/class-odyssey-assets.php index 8973b9d3661eb..1c4b5eb8ffc7d 100644 --- a/projects/packages/stats-admin/src/class-odyssey-assets.php +++ b/projects/packages/stats-admin/src/class-odyssey-assets.php @@ -118,7 +118,7 @@ protected function get_cdn_asset_cache_buster() { /** * Get the cache buster option value. * - * @param string $cache_buster The cache buster. + * @param string|int $cache_buster The cache buster. * @return string|false */ protected function get_cache_buster_option_value( $cache_buster ) { diff --git a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php index 24c2fdade7a8c..2d8df3ef365cb 100644 --- a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php +++ b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php @@ -97,10 +97,10 @@ public function test_get_cdn_asset_cache_buster_force_refresh_expired() { /** * Test remote cache buster. * - * @param mixed $response The response array . - * @param mixed $parsed_args The parsed args . - * @param mixed $url The URL . - * @return array | void + * @param mixed $response The response array. + * @param mixed $parsed_args The parsed args. + * @param mixed $url The URL. + * @return WP_Error | void */ public function break_cdn_cache_buster_request( $response, $parsed_args, $url ) { if ( strpos( $url, '/build_meta.json' ) !== false ) { From c1823f6e51704faa27c76cad0f7fc906b39aaf4e Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 14:19:42 +1300 Subject: [PATCH 6/8] fix type comment --- projects/packages/stats-admin/src/class-odyssey-assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/packages/stats-admin/src/class-odyssey-assets.php b/projects/packages/stats-admin/src/class-odyssey-assets.php index 1c4b5eb8ffc7d..98d59fc3bb3ad 100644 --- a/projects/packages/stats-admin/src/class-odyssey-assets.php +++ b/projects/packages/stats-admin/src/class-odyssey-assets.php @@ -118,7 +118,7 @@ protected function get_cdn_asset_cache_buster() { /** * Get the cache buster option value. * - * @param string|int $cache_buster The cache buster. + * @param string|int|float $cache_buster The cache buster. * @return string|false */ protected function get_cache_buster_option_value( $cache_buster ) { From 8ad71e5dc14207e69b334e52b0f8e44ff5e0a8cf Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 14:35:34 +1300 Subject: [PATCH 7/8] refactoring $this->get_cdn_asset_cache_buster_callable() --- .../tests/php/test-odyssey-assets.php | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php index 2d8df3ef365cb..9b4b6e95e46b8 100644 --- a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php +++ b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php @@ -15,17 +15,15 @@ class Test_Odyssey_Assets extends Stats_Test_Case { * Test remote cache buster. */ public function test_get_cdn_asset_cache_buster() { - list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); - $this->assertEquals( 'calypso-4917-8664-g72a154d63a', $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) ); + $this->assertEquals( 'calypso-4917-8664-g72a154d63a', $this->get_cdn_asset_cache_buster_callable() ); } /** * Test remote cache buster breaking. */ public function test_get_cdn_asset_cache_buster_force_refresh() { - list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); add_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15, 3 ); - $this->assertEquals( time(), floor( $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) / 1000 ) ); + $this->assertEquals( time(), floor( $this->get_cdn_asset_cache_buster_callable() / 1000 ) ); remove_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15 ); } @@ -33,7 +31,6 @@ public function test_get_cdn_asset_cache_buster_force_refresh() { * Test already cached cache buster. */ public function test_get_cdn_asset_cache_buster_already_cached() { - list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); update_option( Odyssey_Assets::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, wp_json_encode( @@ -44,7 +41,7 @@ public function test_get_cdn_asset_cache_buster_already_cached() { ), false ); - $this->assertEquals( 'calypso-4917-8664-123456', $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) ); + $this->assertEquals( 'calypso-4917-8664-123456', $this->get_cdn_asset_cache_buster_callable() ); } /** @@ -61,15 +58,13 @@ public function test_get_cdn_asset_cache_buster_already_cached_expired() { ), false ); - list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); - $this->assertEquals( 'calypso-4917-8664-g72a154d63a', $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) ); + $this->assertEquals( 'calypso-4917-8664-g72a154d63a', $this->get_cdn_asset_cache_buster_callable() ); } /** * Test already cached cache buster expired and failed to fetch new one. */ public function test_get_cdn_asset_cache_buster_failed_to_fetch() { - list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); add_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15, 3 ); update_option( Odyssey_Assets::ODYSSEY_STATS_CACHE_BUSTER_CACHE_KEY, @@ -81,7 +76,7 @@ public function test_get_cdn_asset_cache_buster_failed_to_fetch() { ), false ); - $this->assertEquals( time(), floor( $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) / 1000 ) ); + $this->assertEquals( time(), floor( $this->get_cdn_asset_cache_buster_callable() / 1000 ) ); remove_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15 ); } @@ -89,9 +84,8 @@ public function test_get_cdn_asset_cache_buster_failed_to_fetch() { * Test force refresh cache buster. */ public function test_get_cdn_asset_cache_buster_force_refresh_expired() { - list($get_cdn_asset_cache_buster, $odyssey_assets) = $this->get_cdn_asset_cache_buster_callable(); - $_GET['force_refresh'] = 1; - $this->assertEquals( time(), floor( $get_cdn_asset_cache_buster->invoke( $odyssey_assets ) / 1000 ) ); + $_GET['force_refresh'] = 1; + $this->assertEquals( time(), floor( $this->get_cdn_asset_cache_buster_callable() / 1000 ) ); } /** @@ -115,6 +109,7 @@ protected function get_cdn_asset_cache_buster_callable() { $odyssey_assets = new Odyssey_Assets(); $get_cdn_asset_cache_buster = new \ReflectionMethod( $odyssey_assets, 'get_cdn_asset_cache_buster' ); $get_cdn_asset_cache_buster->setAccessible( true ); - return array( $get_cdn_asset_cache_buster, $odyssey_assets ); + + return $get_cdn_asset_cache_buster->invoke( $odyssey_assets ); } } From 7fcaecc90cc29062a1d27d193e57ec621083752b Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Thu, 24 Oct 2024 14:44:40 +1300 Subject: [PATCH 8/8] rename function and add comment --- .../packages/stats-admin/tests/php/test-odyssey-assets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php index 9b4b6e95e46b8..14e1fb5c3bec9 100644 --- a/projects/packages/stats-admin/tests/php/test-odyssey-assets.php +++ b/projects/packages/stats-admin/tests/php/test-odyssey-assets.php @@ -19,9 +19,9 @@ public function test_get_cdn_asset_cache_buster() { } /** - * Test remote cache buster breaking. + * Test remote cache buster remote error. */ - public function test_get_cdn_asset_cache_buster_force_refresh() { + public function test_get_cdn_asset_cache_buster_remote_error() { add_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15, 3 ); $this->assertEquals( time(), floor( $this->get_cdn_asset_cache_buster_callable() / 1000 ) ); remove_filter( 'pre_http_request', array( $this, 'break_cdn_cache_buster_request' ), 15 );