Global Styles: Invalidate global block styles cache on style change#7017
Global Styles: Invalidate global block styles cache on style change#7017aaronrobertshaw wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I'll be AFK for a couple of days. So please feel free to push changes, rework, or discard this PR. It's only meant to help find a possible solution for 6.6. |
|
I gave this a quick test run on my local and this does seem to fix the issue! |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
joemcgill
left a comment
There was a problem hiding this comment.
Thanks, @aaronrobertshaw! This indeed fixes the bug, but splits the responsibility of cache busting in two separate places—the hash added to the transient name, and also to the block node keys stored in the cache. I'd prefer that the responsibility for cache invalidation be handled in one place.
I've proposed an alternative in #6879 that I think will fix this as well, which I'd appreciate feedback on.
|
Closing in favour of #6879 |
This PR is an initial pass at preventing stale global block styles from being rendered on the frontend in 6.6
Problem
Caching was recently added to the global block styles in
wp_add_global_styles_for_blocks, this was keyed only on the block name or metadata meaning the cached styles were returned even if the styles had recently changed.Proposed Solution
Cache the global block styles using a hash of the style data as well.
Steps to replicate issue on trunk
Copied from #71
Test Instructions
Trac ticket: https://core.trac.wordpress.org/ticket/59595
Props go to @tellthemachines for isolating the cause and @andrewserong for his assistance in debugging also.
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.