[wp-trac] [WordPress Trac] #47279: $post object passed to clean_post_cache action can contain outdated values
WordPress Trac
noreply at wordpress.org
Thu Sep 4 23:35:46 UTC 2025
#47279: $post object passed to clean_post_cache action can contain outdated values
-------------------------------------------------+-------------------------
Reporter: tabrisrp | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future
| Release
Component: Posts, Post Types | Version: 2.5
Severity: normal | Resolution:
Keywords: needs-unit-tests good-first-bug | Focuses: docs
has-test-info needs-testing |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):
* focuses: => docs
* version: => 2.5
Comment:
Yeah, I can see how this would happen & it seems like it was a mistake to
pass the `$post` parameter to the action. Unfortunately, it's a mistake
made in version 2.5 so it's too late to fix it now.
I think this is a documentation fix rather than a code fix. Changing the
hook to `do_action( 'clean_post_cache', $post->ID, get_post( $post->ID )
);` would trigger a database call for the post to reprime the cache.
There are multiple instances in the code base where the post cache is
cleared in a loop. In these cases, that would trigger a database call for
each of the posts being cleared. [https://github.com/WordPress/wordpress-
develop/blob/e3ba953a67d06cc09a9335b914a40ee82c057f7e/src/wp-
includes/post.php#L3892-L3896 ref 1], [https://github.com/WordPress
/wordpress-develop/blob/62f89e94a4656f99f4390fb4f05847f911641ef6/src/wp-
includes/theme.php#L3916-L3926 ref 2], there are others.
It's also pretty risky to start priming the cache in `clean_post_cache()`
as it could affect post updates with order of operations issues.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47279#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list