Repository navigation
perf: skip populate cache refresh for edit lock and session meta - #147
Merged
dnnsjsk merged 1 commit intoOct 22, 2026
Merged
Conversation
_edit_lock (editor open and every Heartbeat tick), _edit_last and session_tokens are bookkeeping and cannot change populated choices. Ignore them, extendable through blockstudio/cache/populate_ignored_meta_keys.
Contributor
|
Included in Blockstudio 7.7.6, now officially released. This PR is merged into main as part of the reviewed release, with full CI and distribution checks passing for the release commit. |
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.
Every meta write rotates the populate cache version (
includes/classes/build-cache.php, the meta hooks ininit()callinvalidate_populate_cache()). WordPress writes some keys purely as bookkeeping:_edit_lockfromwp_set_post_lock()when an editor opens and fromwp_refresh_post_lock()on every Heartbeat tick (wp-admin/includes/post.php,wp-admin/includes/misc.php)_edit_lastnext to a post save that already invalidates throughsave_postsession_tokenson every login and logout (wp-includes/class-wp-user-meta-session-tokens.php)None of them can change what populate returns, but while anyone keeps an editor open, populated choices are rebuilt and the runtime cache file is rewritten about every 30 seconds.
The meta hooks now pass the meta key to a small wrapper,
invalidate_populate_cache_for_meta(). It skips the keys in the newblockstudio/cache/populate_ignored_meta_keysfilter, which defaults to those three, so integrators can add their own high-frequency keys.save_postand all other writes still invalidate.Measured in Playground with a theme that uses custom populate in a block and an extension: a two-minute editing session with a lock refresh every 15 seconds caused 5 version rotations and 5 rewrites of the 48 KB runtime cache file before the change, and 0 after. A regular meta write still refreshes the choices.
Test:
BuildCacheTest::test_editing_and_login_bookkeeping_meta_does_not_rotate_the_populate_versionfails on main and passes with the change;PopulateTestpasses before and after. Docs for the filter are inblocks/hooks/php.mdandgeneral/settings.md. I used@since 7.7.6on the filter, adjust as you like.