Consolidate WP_Theme_JSON_Resolver
changes in both lib/compat/wordpress-6.0
and lib/experimental
#40140
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.
What?
This PR does two things:
lib/compat/6.0/wp-class-theme-json-resolver-6.0.php
has all the changes to be backported.lib/experimental/wp-class-theme-json-resolver-gutenberg.php
has all the changes to be backported and the experimental ones.Why?
By the process we have, we add changes to
lib/compat/6.0
when they are supposed to land in WordPress 6.0 and we add them tolib/experimental
when they need more iteration and should not be backported. This is problematic when the same method contains both experimental changes and changes to be backported.This is the case of
WP_Theme_JSON_Resolver_*::get_theme_data
method, that has changes to be backported and others that should not.How?
The
get_theme_data
method in experimental is the one that will run, so it needs to have all the changes necessary to work well.On the other hand, we also need all those changes (but the experimental ones) in the
get_theme_data
method oflib/compat/6.0
, as to make sure they're backported. Though this method is not called.Alternatives:
lib/experimental
, git history and understand what everything does. Every change to be backported for a method that needs experimental changes needs be ported at experimental._lib_experimental_changes_description
that code atlib/experimental
could use. We'll still need to mark the hook as not to port, so I thought why not doing it directly given it's a oneliner.lib/compat
for example) and mark the changes not to backport via comments, as in:Future
This PR tries to work with the model we have now to make sure everything is contained (we know what to backport) and it works (the experimental method has all the changes).
The existing approach has some pros:
lib/experimental
It also has some cons
lib/experimental
andlib/compat/wordpress-6.0
For now, given how close we're to the WordPress 6.0 cutoff, it seems easier to run with what we have. For the 6.1 cycle this may require further thinking and/or changing the approach to avoid changes not being backported.