-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global Styles: Add style variation partial cache #62610
base: trunk
Are you sure you want to change the base?
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core GitHub repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/class-wp-theme-json-resolver-gutenberg.php |
5c5e69d
to
9640387
Compare
Flaky tests detected in 72f8a82. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9578992360
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Seems to be filtered out in the variations component here somewhere: gutenberg/packages/edit-site/src/components/global-styles/style-variations-container.js Line 37 in d66f4d1
I can see Rust in the REST response and in the return value of |
Ah, so the variations are filtered by isVariationWithSingleProperty, and since Rust only contains colors, it's skipped, and its colors are turned into a "Palette" below in the ColorVariations component. Looks to be expected behavior. |
I've scoped down WordPress/wordpress-develop#6837 to only #62529 as to prevent it from being blocked until this PR is resolved. We'll need to update the backports changelog & create a new one when time comes. |
$locale = get_locale(); | ||
|
||
if ( | ||
isset( static::$style_variations_cache[ $theme_dir ][ $locale ][ $scope ] ) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I withdraw my comment.
Many of the Rust variation's block styles seems to be missing, e.g., "core/calendar"
when the cache is returned here.
It seems to be missing in the return value of $variation = ( new WP_Theme_JSON_Gutenberg( $translated ) )->get_raw_data();
below.
|
||
if ( $variation_scope ) { | ||
$translated = static::translate( $decoded_file, wp_get_theme()->get( 'TextDomain' ) ); | ||
$variation = ( new WP_Theme_JSON_Gutenberg( $translated ) )->get_raw_data(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I'm seeing, many of Rust's block styles aren't registered and are therefore failing the test in ::get_blocks_metadata()
gutenberg/lib/class-wp-theme-json-gutenberg.php
Lines 1080 to 1084 in d66f4d1
$registered_styles = $style_registry->get_all_registered(); | |
foreach ( static::$blocks_metadata as $block_name => $block_metadata ) { | |
if ( ! empty( $registered_styles[ $block_name ] ) ) { | |
$style_selectors = $block_metadata['styleVariations'] ?? array(); | |
I've removed the backport label for this PR. A simpler approach caching only the read json file was merged in #62638. I'll leave this PR open for now however as there are still plans to potentially iterate further on the caching strategy for style variations. |
I learned that the colors & typography panels are only to be filled with style variations that use a single property (e.g.: for color, it should be I'm going to rebase this PR and test again. |
d66f4d1
to
04948a0
Compare
04948a0
to
c99de18
Compare
I've rebased this and it works as expected. Also prepared the corresponding core PR WordPress/wordpress-develop#6857 for us to gauge the impact this may have. I've left some thoughts and asked feedback from core-performance folks. |
I added back the "Backport to beta/RC" label, so we don't forget if this eventually gets merged. However, I'd like to hear feedback from core folks in the core PR before merging this one here. |
I've left some relevant feedback in this PR along with some more general observations to the related Trac ticket, but wanted to post links here for visibility. Is there a better tracking issue in this repo where you all are collaborating on the performance improvements for this feature? Given how fractured the development process is for changes affecting |
This only touches PHP files, so no need to backport it for packages? |
Thanks for double checking, oversharing never hurts. I also want to keep the conversation over there (core PR / trac ticket).
The core trac ticket is the central place for this. |
Thanks for the reminder, I've removed the label. I thought all PRs still had to have that. I guess it's now irrelevant given that we already have the |
Related:
What?
Adds caching to processed theme.json partials for style variations.
Why?
With registration of block style variations moved to a separate
init
action, the processing of/styles
directories, including parsing and translating variation partials, was happening multiple times.How?
Processes all variation partials and stores them in a cache keyed by the theme, then locale.
Testing Instructions