fix: address Phase 1 code review findings

- Serve cache via template_redirect so feeds/404/REST are excluded and
  query conditionals work
- Bypass cache on query strings; key files by md5(host+path) to avoid
  collisions and support multisite
- Write wp-content/wp-recache-cache.php drop-in server and set WP_CACHE
  in wp-config.php so advanced-cache.php actually runs
- Only remove advanced-cache.php on deactivation when it is ours
- Respect DONOTCACHEPAGE, non-200 responses; bots read but never warm
  cache
- Fix comment purge (comment_post_ID) and heartbeat purge ($data arg)
- Fix exclude URLs textarea parsing; purge all when exclusions change
- Enqueue admin purge script on every admin-bar page, not just settings
- Sync tests, add TESTING.md manual test guide
This commit is contained in:
2026-09-13 13:44:30 +02:00
parent 33099591f5
commit d2be239c3f
12 changed files with 309 additions and 78 deletions
+10 -10
View File
@@ -34,26 +34,26 @@ class WP_Recache_Helpers_Test extends WP_UnitTestCase {
public function test_wp_recache_get_cache_path_returns_correct_path() {
$url = 'https://example.com/test-page/';
$expected = WP_RECACHE_CACHE_PATH . 'test-page.html';
$expected = WP_RECACHE_CACHE_PATH . md5('example.com/test-page/') . '.html';
$this->assertEquals($expected, wp_recache_get_cache_path($url));
}
public function test_wp_recache_get_cache_path_handles_root_url() {
$url = 'https://example.com/';
$expected = WP_RECACHE_CACHE_PATH . 'index.html';
$expected = WP_RECACHE_CACHE_PATH . md5('example.com/') . '.html';
$this->assertEquals($expected, wp_recache_get_cache_path($url));
}
public function test_wp_recache_get_cache_key_returns_md5_hash() {
$url = 'https://example.com/test-page/';
$expected = md5('/test-page/');
$this->assertEquals($expected, wp_recache_get_cache_key($url));
public function test_wp_recache_get_cache_path_no_collision_between_nested_urls() {
$a = wp_recache_get_cache_path('https://example.com/a/b/');
$b = wp_recache_get_cache_path('https://example.com/ab/');
$this->assertNotEquals($a, $b);
}
public function test_wp_recache_get_cache_key_handles_root_url() {
$url = 'https://example.com/';
$expected = md5('/');
$this->assertEquals($expected, wp_recache_get_cache_key($url));
public function test_wp_recache_get_cache_path_no_collision_between_hosts() {
$a = wp_recache_get_cache_path('https://site1.example.com/');
$b = wp_recache_get_cache_path('https://site2.example.com/');
$this->assertNotEquals($a, $b);
}
public function test_wp_recache_is_mobile_returns_false_for_desktop_user_agent() {