Skip to content

Suspend calling wp_cache_set_posts_last_changed() when touching post meta in WP_Sync_Post_Meta_Storage#11002

Draft
westonruter wants to merge 2 commits intoWordPress:trunkfrom
westonruter:fix/rtc-posts-last-changed-cache-preservation
Draft

Suspend calling wp_cache_set_posts_last_changed() when touching post meta in WP_Sync_Post_Meta_Storage#11002
westonruter wants to merge 2 commits intoWordPress:trunkfrom
westonruter:fix/rtc-posts-last-changed-cache-preservation

Conversation

@westonruter
Copy link
Member

@westonruter westonruter commented Feb 23, 2026

Trac ticket: https://core.trac.wordpress.org/ticket/64696

Use of AI Tools

Gemini CLI authored a commit to help add phpdoc for the with_suspended_posts_last_changed_update() method.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

westonruter and others added 2 commits February 22, 2026 20:23
…h_suspended_posts_last_changed_update()

Co-authored-by: gemini-cli <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@chriszarate
Copy link

I can't speak to whether this is the correct performance mitigation, but the code change looks good in the context of the sync provider. 👍 Thank you!

@mindctrl
Copy link

mindctrl commented Feb 23, 2026

I'll try to confirm the level of accuracy of the screenshots included here to be sure there are no bugs in the way I'm tracking this, but here's a quick look at the difference before and after this PR:

Before

image

After

image

Edit: Note the before/after timestamps are opposite the way I've labeled them. This is due to running a 2nd check on the "before" run to double check my results.

I'm testing this with 3 Playwright clients making edits to the same post.

@westonruter
Copy link
Member Author

westonruter commented Feb 23, 2026

@mindctrl it might be helpful to also have a client that is continuously doing reads to a function that uses wp_cache_get_last_changed( 'posts' ) as the salt for a return value that should be cached in object cache, to simulate the impact of having this on a live site getting a lot of traffic. This would be in a addition to having sync clients open. For example, get_archives() would continuously have its cache impacted by sync changes.

It seems like there are a lot of examples where unrelated post and post meta changes are causing object cache invalidations needlessly. (Cache invalidation is hard!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants