[wp-trac] [WordPress Trac] #63877: WP_Term_Query::get_terms() - check return value of get_term()
WordPress Trac
noreply at wordpress.org
Tue Aug 26 17:24:23 UTC 2025
#63877: WP_Term_Query::get_terms() - check return value of get_term()
--------------------------+-----------------------------
Reporter: josephscott | Owner: SergeyBiryukov
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 6.9
Component: Taxonomy | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch | Focuses:
--------------------------+-----------------------------
Changes (by SergeyBiryukov):
* status: accepted => closed
* resolution: => fixed
Comment:
In [changeset:"60661" 60661]:
{{{
#!CommitTicketReference repository="" revision="60661"
Taxonomy: Check the result of `get_term()` in
`WP_Term_Query::get_terms()`.
`get_term()` can return `WP_Error` or `null` on failure, so the result
should be verified as a `WP_Term` instance before accessing the `count`
property.
This commit prevents a PHP warning if `get_term()` returns `null` for a
child term:
{{{
Warning: Attempt to read property "count" on null
}}}
Follow-up to [27458], [37572].
Props josephscott, coleatkinson1, kebbet, jakariaistauk, sabernhardt,
westonruter, SergeyBiryukov.
Fixes #63877.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63877#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list