Opened 4 years ago
Last modified 8 months ago
#51811 new enhancement
Query inconsistency between WP_Query and WP_Term_Query
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Query | Keywords: | good-first-bug has-patch has-unit-tests |
Focuses: | coding-standards | Cc: |
Description
For the sake of standardization and simplicity would it be beneficial to use 's' for searches in WP_Term_Query rather than using 'search'?
$wpquery = new WP_Query( array( 's'=>'search term' ) );
$wptermquery = new WP_Term_Query( array( 'search'=>'search term' ) );
Not entirely sure why there's a differentiation between how a search term is used in the query args. For the sake of standardization and a reduction in confused developers (like I was about 30 minutes ago) I think this is worth some consideration.
Change History (6)
#1
@
4 years ago
- Keywords needs-patch good-first-bug added; dev-feedback removed
- Version changed from 5.5.3 to 4.6
This ticket was mentioned in PR #780 on WordPress/wordpress-develop by JWardee.
4 years ago
#2
- Keywords has-patch has-unit-tests added; needs-patch removed
The 'search' parameter takes precendence if both 's' and 'search' are populated. I've included two unit tests:
- Test that the 's' returns the correct terms
- Test that 'search' takes precedence when both 's' and 'search' are used
This is my first pull request so please let me know if anything needs amending! :)
Fixes: https://core.trac.wordpress.org/ticket/51811
Trac ticket:
github-actions[bot] commented on PR #780:
4 years ago
#3
Hi @JWardee! 👋
Thank you for your contribution to WordPress! 💖
It looks like this is your first pull request to wordpress-develop
. Here are a few things to be aware of that may help you out!
No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.
Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.
More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post.
Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.
If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.
The Developer Hub also documents the various coding standards that are followed:
- PHP Coding Standards
- CSS Coding Standards
- HTML Coding Standards
- JavaScript Coding Standards
- Accessibility Coding Standards
- Inline Documentation Standards
Thank you,
The WordPress Project
This ticket was mentioned in PR #6746 on WordPress/wordpress-develop by @thehercules.
9 months ago
#4
Fixes Ticket #51811
For searching, in addition to search, now just like in WP_Query class we can pass 's' as a parameter. This aims in keeping the code consistent.
@thehercules commented on PR #6746:
9 months ago
#5
@westonruter I am not sure why the unit tests are failing, also there is no re-running jobs option. Can you guide me on how should I proceed further.
@thehercules commented on PR #6746:
8 months ago
#6
Hey @mukeshpanchal27 , I have made the suggested changes. Can you review them.
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
Yes, I think it would make sense to have
s
as an alias forsearch
here inWP_Term_Query
.Changing the version to 4.6 as the earliest applicable, since
WP_Term_Query
was introduced in [37572] / #35381.That said, the
search
argument forget_terms()
was introduced in [6799], so the inconsistency dates back to WordPress 2.5.