Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#48811 closed defect (bug) (duplicate)

Problem with is_page function when get_queried_object() returns null

Reported by: nwjames's profile nwjames Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.3
Component: Query Keywords:
Focuses: Cc:

Description

My scenario is that I am trying to test a feed. I am trying to do a generic feed, ie. of documents where there are none corresponding.

I get these PHP messages:
PHP Notice: Trying to get property 'ID' of non-object in /usr/share/wordpress/wp-includes/class-wp-query.php on line 3966
PHP Notice: Trying to get property 'post_title' of non-object in /usr/share/wordpress/wp-includes/class-wp-query.php on line 3968
PHP Notice: Trying to get property 'post_name' of non-object in /usr/share/wordpress/wp-includes/class-wp-query.php on line 3970

When I put additional debug in, I see that $page_obj is set from get_queried_object() - which is used without an isset test.

The path to this is:
redirect_canonical (wp-includes/canonical.php) line 498 ->
is_front_page (wp-includes/query.php) 456 ->
is_front_page (wp-includes/class-wp-query.php) 3879

Options show_on_front is set to page and page_on_front has a value so is_page is called with a value.

Change History (2)

#1 @nwjames
5 years ago

  • Summary changed from Problem with is_page function when get_queried_object() reurns null to Problem with is_page function when get_queried_object() returns null

#2 @SergeyBiryukov
5 years ago

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

Hi there, welcome to WordPress Trac!

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

Note: See TracTickets for help on using tickets.