[wp-trac] [WordPress Trac] #54619: Attempt to read property "post_type" on null

WordPress Trac noreply at wordpress.org
Tue Dec 14 09:06:14 UTC 2021


#54619: Attempt to read property "post_type" on null
-------------------------------+-----------------------------
 Reporter:  Grzegorz.Janoszka  |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Query              |    Version:
 Severity:  minor              |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 In PHP 8 we get:

 PHP message: PHP Warning:  Attempt to read property "post_type" on null in
 /website/wp-includes/class-wp-query.php on line 4196PHP message: PHP
 Warning:  Attempt to read property "post_type" on null in /website/wp-
 includes/class-wp-query.php on line 4196" while reading response header
 from upstream, client: 3.249.153.207, server: website.com, request: "GET
 /sports/feed/

 It is about function is_singular:

                $post_obj = $this->get_queried_object();
                return in_array( $post_obj->post_type, (array) $post_types,
 true );

 get_queried_object may return null and the next command doesn't validate
 it before accessing post_type of null object.

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


More information about the wp-trac mailing list