[wp-trac] [WordPress Trac] #45800: Add short circuits for WP_Comment_Query
WordPress Trac
noreply at wordpress.org
Mon Jun 24 22:30:13 UTC 2019
#45800: Add short circuits for WP_Comment_Query
--------------------------------------+------------------------------
Reporter: spacedmonkey | Owner: adamsilverstein
Type: enhancement | Status: assigned
Priority: normal | Milestone: 5.3
Component: Comments | Version: 3.1
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------------------
Comment (by felipeelia):
Hi @spacedmonkey! I didn't run automated tests on it but giving a quick
look it seems to work fine. I think the `$comment_ids` doc should explicit
the special cases, like `fields=ids` and `count=true`, though.
I do like the simplicity of your patch. If it is clear somewhere that
using the `comments_pre_query` filter, the developer takes the full
responsibility of returning the right type, i.e.,
* an int when `$this->query_vars['count']`
* an array of ids when `'ids' == $this->query_vars['fields']` OR
* an array of WP_Comment objects, since it passes through `$comments =
array_map( 'get_comment', $_comments );` near the end
This should work good (if we consider the scenario with that
`wp45800_comments_pre_query` I wrote before, for example). IMHO opinion
these tests should be kept inside the method just to improve consistency
on responses but perhaps I'm being too cautious here :)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45800#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list