Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#54619 closed defect (bug) (duplicate)

Attempt to read property "post_type" on null

Reported by: grzegorzjanoszka's profile Grzegorz.Janoszka Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Query Keywords:
Focuses: Cc:

Description

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.

Change History (1)

#1 @SergeyBiryukov
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome back to WordPress Trac!

Thanks for the report, we're already tracking this issue in #29660.

Note: See TracTickets for help on using tickets.