Fix for WP_Theme_JSON_Resolver_Gutenberg::get_merged_data#48644
Merged
Fix for WP_Theme_JSON_Resolver_Gutenberg::get_merged_data#48644
WP_Theme_JSON_Resolver_Gutenberg::get_merged_data#48644Conversation
Contributor
|
@oandregal you backported this change here: WordPress/wordpress-develop#4145, so I'm removing the label. Unless I'm missing something. --edit I guess it doesn't hurt to add it to |
oandregal
commented
Mar 1, 2023
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.
Related trac ticket https://core.trac.wordpress.org/ticket/57824
Reverts WordPress/wordpress-develop#3441
Backport PR WordPress/wordpress-develop#4145
What
This PR fixes a bug by which the reset function of the global styles sidebar wouldn't work as expected in the site editor.
How to reproduce
Take the following steps:
Note that if this is saved and then site editor reloaded, the proper data is shown.
How this PR fixes the issue
By reverting WordPress/wordpress-develop#3441 which was the one that introduced the issue.
That PR changed the
get_merged_datacode to (pseudo-code):However, by doing so, the base object (
$result) is modifying the$coreobject directly, and$coreends up storing the consolidated values instead of only the ones coming from thetheme.jsonprovided by core.This is problematic because
$coredata is cached. Take, for example, the following scenario:The expected output for
$datais that it should not have data coming from the 'custom' origin, however, it does.The fix is reverting the change and use an empty object as base (pseudo-code):
Performance
(The performance data is taken from core, not Gutenberg. Left here as a section for visibility).
This is a bug that needs to be fixed. I thought about running some performance analysis anyway, given the intent of the PR this reverts was improving performance. Given the improvements introduced in 6.2, reverting the PR doesn't affect performance.
Using XDebug (only for completeness, we should not use data extracted from a xdebug profiler to make perf decisions, as there's a cost to observability):
WP_Theme_JSON_Resolver::get_merged_dataWP_Theme_JSON->mergeUsing production code (see raw data): the variance is sub-millisecond, so it may be attributed to the measuring conditions.