[wp-trac] [WordPress Trac] #29660: Functions in wp_includes/query.php assume non-null return value from get_queried_object
WordPress Trac
noreply at wordpress.org
Mon Mar 21 04:38:13 UTC 2022
#29660: Functions in wp_includes/query.php assume non-null return value from
get_queried_object
-------------------------------------------------+-------------------------
Reporter: yellyc | Owner:
| SergeyBiryukov
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: Future
| Release
Component: Query | Version: 4.0
Severity: normal | Resolution:
Keywords: 2nd-opinion has-patch has-unit- | Focuses:
tests |
-------------------------------------------------+-------------------------
Comment (by zikubd):
I'm getting similar warnings while trying to call this function on PHP
version 8:
{{{
Warning: Attempt to read property "ID" on null in
/Users/wedevs/Sites/Theme_Rat/wp-includes/class-wp-query.php on line 4123
Warning: Attempt to read property "post_title" on null in
/Users/wedevs/Sites/Theme_Rat/wp-includes/class-wp-query.php on line 4125
Warning: Attempt to read property "post_name" on null in
/Users/wedevs/Sites/Theme_Rat/wp-includes/class-wp-query.php on line 4127
}}}
How to reproduce this warning:
{{{
add_action( 'posts_results', 'my_prefix_func_name', 10, 2 );
function my_prefix_func_name( $posts, $query ) {
if ( is_page() ) { // here those warnings are triggred
// extra logic
}
return $posts;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29660#comment:49>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list