Automattic / Automattic/wp-super-cache

Cache does not refresh when a comment is made on attachment pages

Open
#899 4 comments 0 reactions 0 assignees View on GitHub
[Plugin] Super Cache bug
Dominant language
PHP
Stars
436
Forks
130
Avg merge
15h 11m
Merged PRs (30d)
10

Description

When an anonymous user comments on a media attachment (e.g. site.com/post/attachment), cache is not cleared. I've looked at the debug log and the plugin seems to think it's a draft post:

```
21:26:11 105360 /wp-comments-post.php wp_cache_get_cookies_values: return:
21:26:11 105360 /wp-comments-post.php In WP Cache Phase 2
21:26:11 105360 /wp-comments-post.php Setting up WordPress actions
21:26:11 105360 /wp-comments-post.php Created output buffer
21:26:12 105360 /wp-comments-post.php wp_cache_post_edit: draft post, not deleting any cache files. status: inherit
21:26:12 105360 /wp-comments-post.php wp_cache_post_change: draft post, not deleting any cache files.
21:26:12 105360 /wp-comments-post.php Post 20272 changed. Update cache.
21:26:12 105360 /wp-comments-post.php wp_cache_post_change: draft post, not deleting any cache files.
21:26:12 105360 /wp-comments-post.php Not caching POST request.
21:26:12 105360 /wp-comments-post.php wp_cache_maybe_dynamic: returned $buffer
```

It works as expected if I disable the check for post status using WPSCFORCEUPDATE in wp-config.php:

`define('WPSCFORCEUPDATE', true);`

It appears that when the plugin checks for the attachment's status, "inherit" is returned, and it fails this check in wp-cache-phase2.php:

```
if ( false == defined( 'WPSCFORCEUPDATE' ) && !in_array($post->post_status, array( 'publish', 'private' ) ) ) {
wp_cache_debug( 'wp_cache_post_edit: draft post, not deleting any cache files. status: ' . $post->post_status, 4 );
return $post_id;
}
```

It should instead get the parent's post status.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.