Opened 9 months ago
Closed 3 months ago
#61094 closed defect (bug) (fixed)
Unsupported `count` argument in `WP_Term_Query` DocBlock
Reported by: | Tyrannous | Owned by: | desrosj |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | commit dev-reviewed |
Focuses: | docs | 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 (19)
This ticket was mentioned in Slack in #core-test by ankit-k-gupta. View the logs.
9 months ago
This ticket was mentioned in PR #6770 on WordPress/wordpress-develop by @snehapatil02.
8 months ago
#2
- Keywords has-patch added
#5
follow-up:
↓ 7
@
5 months ago
Hi @swissspidy, the attached PR (apparently AI-generated) removes the count
DocBlock parameter.
However, as I wrote in the ticket description, wouldn't it make more sense to add support for it to achieve feature parity with other WP_*_Query
classes?
Thanks!
@Tyrannous commented on PR #6770:
5 months ago
#6
Hi @snehapatil2001, the PR removes the count
DocBlock parameter.
However, as I wrote in the Trac ticket description, wouldn't it make more sense to add support for it to achieve feature parity with other WP_*_Query
classes?
Thanks!
#7
in reply to:
↑ 5
@
5 months ago
Hi there, thanks for the ticket!
Replying to Tyrannous:
However, as I wrote in the ticket description, wouldn't it make more sense to add support for it to achieve feature parity with other
WP_*_Query
classes?
Indeed, I think that would be the preferred solution here.
@jtsternberg commented on PR #6770:
4 months ago
#8
wouldn't it make more sense to add support for it to achieve feature parity with other WP_*_Query classes?
Isn't that what $fields['count']
is for?
Also, if we're removing the doc block, we should also remove from query_var_defaults
:
#9
@
3 months ago
I agree adding support for count
would be appropriate for the query class. I think a follow up ticket can be created for that as an enhancement.
For the purposes of WordPress 6.7 (which is no longer accepting enhancements) I think removing the documentation is the best fix.
#10
@
3 months ago
- Owner set to peterwilsoncc
- Resolution set to fixed
- Status changed from new to closed
In 59261:
@peterwilsoncc commented on PR #6770:
3 months ago
#11
This ticket was mentioned in PR #7680 on WordPress/wordpress-develop by @johnbillion.
3 months ago
#12
#13
@
3 months ago
- Resolution fixed deleted
- Status changed from closed to reopened
This is still referenced in two other docs and included as a default value for the args.
This ticket was mentioned in Slack in #core by joemcgill. View the logs.
3 months ago
@peterwilsoncc commented on PR #7680:
3 months ago
#16
#17
@
3 months ago
- Keywords dev-feedback added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for backport consideration of r59325 to the 6.7 branch upon sign off by a second committer.
## 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.