-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add WP_Object_Cache
to the gutenberg_get_global_settings
method
#45372
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
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.
Consider these lines
https://github.com/WordPress/wordpress-develop/blob/bb948c5f6d462dc43483f198d36e9b0948d2e5f1/src/wp-includes/class-wp-theme-json-resolver.php#L297
get_default_block_editor_settings has calls to get_options for image sizes,
is_rtl
related to langaguge setting of the user,get_default_block_categories
that is filterable,get_allowed_mime_types
filterable, andget_theme_support
that can removed. How are all these cases invalidated?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.
This is great feedback:
get_theme_support
,get_default_block_categories
,get_allowed_mime_types
are filtered by a consumer: either themes or plugins. We clean the cache when a plugin is activated/deactivated, theme switch, etc.. so these cases are covered.is_rtl
: I need to look at this one. We may need to invalidate the cache upon language switches as well.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.
As noted, updating a plugin could change the code. Also what if someone updates their plugin by uploading it using FTP. Something I have done in the past and is very common.
Is_rtl can be related to the current user, so can not be cached ever. We need a rethink here.
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.
When someone updates something via FTP, this code will work perfectly in the next request if they don't use a persistent cache plugin. If they do, they can always clear the cache.
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.
Yes, but currently, there are no other parts of core, that require you to flush caches on FTP uploads. Changing this behavior, would be a breaking change, which is something we need avoid at all costs.
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.
This is different theme by default are not a persistent cache group. See
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.
Here we are dealing with site styles that are related to what a theme does. In that case, shouldn't we just follow the same approach and make sure this cache is not in a persistent cache group?
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.
Although get_default_block_editor_settings gets this information, it is not used at all for the purpose of computing theme. json related information, so even if filters change this, it does not affect the output of the cached functions.
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.
Wow, I never followed that code path. Calling
get_default_block_editor_settings
is wasteful then. We should fix that ASAP. To that end I have created #46112.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.
In this PR, I worked on adding caching to theme_json_resolver, as had core unit tests fail. WordPress/wordpress-develop#3624.
This was because of add / removing theme supports. I don't think we should merge this until we have solution to this problem.