Make WordPress Core

Opened 8 weeks ago

Last modified 11 days ago

#61094 new defect (bug)

Unsupported `count` argument in `WP_Term_Query` DocBlock

Reported by: tyrannous's profile Tyrannous Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:


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.

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.

8 weeks ago

This ticket was mentioned in PR #6770 on WordPress/wordpress-develop by @snehapatil02.

11 days ago

  • Keywords has-patch added

## Ticket

## Description

  • This PR, which involves removing the unsupported count argument from the DocBlock of the WP_Term_Query::__construct method.
  • Currently, the DocBlock mentions the count argument, but it is not utilized in the WP_Term_Query::get_terms method. This leads to potential confusion for developers.

## Changes Made

  • Removed the count argument description from the WP_Term_Query::__construct method's DocBlock.

## Context
The WP_Term_Query class provides methods for querying terms in WordPress. The count 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

  • [ ] Verified that the count argument description is removed from the WP_Term_Query::__construct DocBlock.
  • [ ] Tested the functionality of the WP_Term_Query class to ensure no regressions occurred.
  • [ ] Reviewed and verified the changes locally.
Note: See TracTickets for help on using tickets.