Multiple clean_post_cache() calls when saving a post due to post revisions

Description

When a post is saved, clean_post_cache() is called for that post. Immediately afterward, the post revision is inserted and clean_post_cache() is called again for that new post row.

Since the current implementation of post revisions does not allow revision edit, has no taxonomy associated with revisions, has no post meta, and shows up in no archive, we can get away with never calling clean_post_cache() during a post revision insert.

If a plugin does any of those things, it can still call clean_post_cache() from any of a few available API actions.

Attached.

I don't know if this is worth fixing. I don't know how much of a performance impact this "bug" has.

looks more like a bug to me then an enhancement. the hint to wp_suspend_cache_invalidation() is misleading as well (does not fix anything, just only a bad workaround if used for this. patch does not apply any longer anyway.

Here's what a typical execution looks like, for saving an existing post:

wp_insert_post() triggers get_post(), fetching from the DB the current row of the post

The revision gets created, triggering clean_post_cache(), which (since only a post ID is passed) fetches the row from the DB

As the cache is cleared, the ensuing get_post() then fetches the revision's row from the DB again

The main post's cache is cleared, then the post is again pulled from the DB

The only thing that could be avoided is avoiding some clean_post_cache() work when we are inserting a new post. Not even all of it, because we'll probably still want to make sure that the hook fires and certain things get cleared, like wp_get_archives, get_pages, etc (these are all being moved to incrementors, but still).

But is it really a bad thing to force things like wp_cache_delete( $post->ID, 'posts' );? Just to make sure there is absolutely no cache pollution.

So I think this is wontfix. In 3.5, removed the double clean_post_cache() calls (it used to happen twice in wp_insert_post(), one of them on the save_post hook) and prevented children caching clearing, which alleviated the vast majority of this.

Also, revisions are getting more powerful. They're eventually going to have metadata, and a lot of plugins (like Edit Flow and Post Forking) have an interest in strengthening revisions. Given there is barely any performance impact, I'm closing this.