[wp-trac] [WordPress Trac] #57741: Core throwing 'Attempt to read property "post_type" on null'

WordPress Trac noreply at wordpress.org
Fri Feb 17 04:04:23 UTC 2023


#57741: Core throwing 'Attempt to read property "post_type" on null'
--------------------------+-----------------------------
 Reporter:  haykuro       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.1.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 A calls B. B calls C.

 C is calling get_post() passing in args from B.

 C then proceeds to immediately use the results of get_post()
 ($post->post_type) without checking the response, resulting in an edge
 condition where a warning is thrown: Attempt to read property "post_type"
 on null

 A:
 https://github.com/WordPress/WordPress/blob/f0789b64238a97adc3ce0c9b8cdf33c1753f550c
 /wp-admin/post.php#L186-L189

 B:
 https://github.com/WordPress/WordPress/blob/f0789b64238a97adc3ce0c9b8cdf33c1753f550c
 /wp-admin/edit-form-blocks.php#L249-L253


 C:
 https://github.com/WordPress/WordPress/blob/f0789b64238a97adc3ce0c9b8cdf33c1753f550c
 /wp-includes/media.php#L4552-L4558

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


More information about the wp-trac mailing list