Opened 3 months ago
Last modified 7 weeks ago
#61094 new defect (bug)
Unsupported `count` argument in `WP_Term_Query` DocBlock
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
The DocBlock of WP_Term_Query::__construct
mentions the count
argument:
count
bool
Whether to return a term count. If true, will take precedence over$fields
. Default false.
–https://developer.wordpress.org/reference/classes/WP_Term_Query/__construct/
However, this argument is not used in \WP_Term_Query::get_terms
, so it should either be removed from the DocBlock or support should be added.
The erroneous DocBlock element has been in core since WordPress 4.6, when WP_Term_Query
was introduced in #35381. There, @flixos90 proposed the first iteration of WP_Term_Query
in attachment:35381.diff:ticket:35381, which included support for it (lines 347–351). However, when revising the approach in attachment:35381.2.diff:ticket:35381, @boonebgorges kept DocBlock but didn't take over the actual code. This went unnoticed and landed in core.
Note that other WP_*_Query
classes indeed support a count
argument, so while removing it from the DocBlock would be a quick win, it would probably make more sense to actually add support for it.
Change History (2)
This ticket was mentioned in Slack in #core-test by ankit-k-gupta. View the logs.
3 months ago
This ticket was mentioned in PR #6770 on WordPress/wordpress-develop by @snehapatil02.
7 weeks ago
#2
- Keywords has-patch added
## Ticket
https://core.trac.wordpress.org/ticket/61094
## Description
count
argument from the DocBlock of theWP_Term_Query::__construct
method.count
argument, but it is not utilized in theWP_Term_Query::get_terms
method. This leads to potential confusion for developers.## Changes Made
count
argument description from theWP_Term_Query::__construct
method's DocBlock.## Context
The
WP_Term_Query
class provides methods for querying terms in WordPress. Thecount
argument was initially proposed but later removed from the code, while the DocBlock remained unchanged. This PR aligns the DocBlock with the actual code behaviour, ensuring clarity and consistency in the documentation.## Testing
count
argument description is removed from theWP_Term_Query::__construct
DocBlock.WP_Term_Query
class to ensure no regressions occurred.