[wp-trac] [WordPress Trac] #61094: Unsupported `count` argument in `WP_Term_Query` DocBlock

WordPress Trac noreply at wordpress.org
Mon Apr 29 12:08:44 UTC 2024


#61094: Unsupported `count` argument in `WP_Term_Query` DocBlock
--------------------------+-----------------------------
 Reporter:  Tyrannous     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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/#:~:text=.-,count,bool,-Whether%20to%20return
 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61094>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list