Backport: invalidates_query_cache meta parameter#76687
Draft
Conversation
Prevents RTC meta keys (wp_sync_awareness, wp_sync_update) from invalidating the posts cache group's last_changed timestamp on every write. This avoids cache invalidation storms during high-frequency collaborative editing. Uses hook-based interception with a standalone registry since Core's register_meta() cannot be modified. When WordPress 7.0 ships with the native implementation, this backport is automatically disabled via function_exists guard. New file: lib/compat/wordpress-7.0/post-meta-cache.php - gutenberg_register_non_cacheable_post_meta() to register keys - wp_post_meta_invalidates_query_cache() public API - Replaces Core hooks with conditional version that checks registry Modified: lib/compat/wordpress-7.0/collaboration.php - Register RTC meta keys as non-cacheable Modified: lib/load.php - Load post-meta-cache.php before collaboration.php See: https://core.trac.wordpress.org/ticket/64696 See: WordPress/wordpress-develop#11290
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Backports WordPress Core PR #11290: Allow registering post meta keys that skip query cache invalidation.
Why?
RTC (real-time collaboration) meta keys (
wp_sync_awareness,wp_sync_update) are written at high frequency during collaborative editing. Each write was invalidating the posts cache group'slast_changedtimestamp site-wide, causing all post queries to miss their caches. This backport prevents non-cacheable meta keys from triggering cache invalidation.How?
Uses hook-based interception since Core's
register_meta()cannot be modified:lib/compat/wordpress-7.0/post-meta-cache.phpwith standalone registryadded/updated/deleted_post_metahooks with conditional versionTesting
wp_cache_get_last_changed( 'posts' )! function_exists( 'wp_post_meta_invalidates_query_cache' )