2.x Remove unused Term::get_term_from_query() function#2664
Merged
Conversation
nlemoine
previously approved these changes
Feb 28, 2023
Member
There was a problem hiding this comment.
Is that a case we still want to support? Is this the intended behavior for Timber::get_term()?
I didn't event know that method existed 😅
This an absolute no to me, I don't see any valid use case where getting the term from the tax query should be returned with this kind of method. It should only return the current queried term.
Member
Author
|
@nlemoine Thanks for your feedback! I added a note to the Upgrade Guide about the removed logic in I’m sure in the past this logic made some developer’s life easier in very specific use cases. But these kind of gems are the ones that can lead to unexpected behavior quickly. So I’m happy to remove them. |
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:
Issue
I found a function that is not used anymore.
Solution
Remove the function.
Impact
Minimal. The function that gets the term from the main query is now covered through
Timber::get_term()and the term factory.timber/src/Timber.php
Lines 714 to 718 in 056c6a1
Only the protected function
Term::get_term_from_query()can’t be used anymore.Considerations
There’s an additional check for a tax query that was added in #521:
timber/src/Term.php
Lines 142 to 144 in 056c6a1
The logic there seems to be: When the global query includes a tax query, get the first term from that query. Is that a case we still want to support? Is this the intended behavior for
Timber::get_term()? Or could it also be considered as unexcepted?Testing
Do we need more testing?