-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Merged data should consider origin to return early #45969
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f2b0c16
Bail early for given origin
oandregal 4683653
Remove method from experimental, it is stable
oandregal 1eabb78
Only call set spacing presets when necessary
oandregal 845495d
Add test coverage per origin
oandregal 3a5602a
Add blocks origin test and improve them all
oandregal 60ec9b7
Extract utility functions
oandregal 40bb25c
Improve block styles check
oandregal 795319a
Clean cached data
oandregal 6865e70
Fix lint issues
oandregal 1de4692
Add the spacing sizes generation back in before final return
glendaviesnz 3b0e7bf
Update phpunit/class-wp-theme-json-resolver-test.php
oandregal 75c1202
Fix suggestions
oandregal 7228291
Use data provider in test
oandregal 6d06e33
Inline utility functions
oandregal 07903d3
Fix lint issues
oandregal 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
Next
Next commit
Bail early for given origin
- Loading branch information
commit f2b0c16b9d84e4e79022d12dfceed66621c1f56d
There are no files selected for viewing
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
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.
So depending on origin, this function is you more and less information. This is very confusing and even the comment doesnt help explain why this is done at all.
First of all, this is confusing, as the naming seems a little off. Origin means what in this context? Why would you only want to load parts of this data? Why not load the lot?
Instead of param, why not function names, like
get_theme_data_for_blocks,
get_theme_data_for_user,
get_theme_data_for_theme.
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.
That's how the domain works: depending on some context, we need one piece of data or another. Existing use cases are editor vs front-end, or themes with or without theme.json.
Note that the way this is set up is prior to this PR. This PR only fixes the existing behavior. Whether this could have been done differently is out of scope for this PR.
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.
I agree with @spacedmonkey that it would be better to have separate functions (or even classes) for each type of origin:
or
At the same time, I understand @oandregal 's point that the goal of this PR is mainly refactoring/optimization.
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.
That's a conversation separate from this PR. I also want to share my perspective on that: as a collective, we have limited number of hours to produce work, so I tend to favor work that has an impact on users or developer experience. Given this class is private and consumers should use the public methods (see), I'd personally refrain from refactoring for refactor's sake. If anything, we should aim to remove/deprecate these class (and its methods) entirely.
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.
Also, note that there already are separate methods to get the individual origins:
The
get_merged_datamethod implements the algorithm that merges the sources together.