[wp-trac] [WordPress Trac] #55722: Inconsistent guard conditions in query.php
WordPress Trac
noreply at wordpress.org
Sun May 22 15:16:02 UTC 2022
#55722: Inconsistent guard conditions in query.php
-------------------------+------------------------
Reporter: vdankbaar | Owner: vdankbaar
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.1
Component: Query | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch | Focuses:
-------------------------+------------------------
Changes (by SergeyBiryukov):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"53429" 53429]:
{{{
#!CommitTicketReference repository="" revision="53429"
Query: Check if `$wp_query` is set in query loop functions.
This avoids a PHP fatal error if any of these functions are called too
early:
* `have_posts()`
* `in_the_loop()`
* `rewind_posts()`
* `the_post()`
* `have_comments()`
* `the_comment()`
bringing some consistency with conditional tags: `is_single()`,
`is_home()`, etc.
This commit also removes unnecessary `return` from `the_comment()`, for
consistency with `the_post()`. As `WP_Query::the_comment()` does not have
a return value, this statement did not have any effect in practice.
Follow-up to [4934], [8807], [16947], [17068], [17083], [49147], [53395],
[53396], [53400].
Props vdankbaar, thijso, teunvgisteren, timkersten655, SergeyBiryukov.
Fixes #55722.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55722#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list