[wp-trac] [WordPress Trac] #56354: With PHP 8.0.x, WordPress class-wp-query.php core file throws "Attempt to read property “post_type” on null"

WordPress Trac noreply at wordpress.org
Tue Aug 9 11:52:36 UTC 2022


#56354: With PHP 8.0.x, WordPress class-wp-query.php core file throws "Attempt to
read property “post_type” on null"
--------------------------+-----------------------------
 Reporter:  deksar        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.0
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-----------------------------
 I got the following PHP warning (on PHP 8.0.20), I have no idea what to do
 but my error_log file is getting extremely filled with this.

 “Attempt to read property “post_type” on null in <b>/home/xx/public_html
 /wp-includes/class-wp-query.php</b> on line 4338 **on any URL ending with
 mysite.com/category/feed/**

 (feed displays, however the error is at the top of the page)

 I’ve searched for that warning message on Google and I can say there’re
 thousands (no joke) of websites indexed with that warning message in the
 results.

 So, it seems that’s a very common WordPress problem.

 The warning appears only in /feed/ pages, the mentioned line in class-wp-
 query.php file contains:
 "**return in_array( $post_obj->post_type, (array) $post_types, true );**"

 **Wordpress version: 6.0.1**

 Just wanted to report it as there're thousands of websites with the same
 results on Google, and while it's not generated by any plugin but a
 WordPress core file itself.

 And it seems this one happens only when having PHP version 8.0.

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


More information about the wp-trac mailing list