Make WordPress Core

Opened 20 months ago

Last modified 20 months ago

#57741 new defect (bug)

Core throwing 'Attempt to read property "post_type" on null'

Reported by: haykuro's profile haykuro Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.1.1
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

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

Change History (1)

#1 @SergeyBiryukov
20 months ago

  • Component changed from General to Posts, Post Types
Note: See TracTickets for help on using tickets.