Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#23340 closed defect (bug) (duplicate)

get_page_template_slug( $post_id = null ) needs hardening against the null scenario

Reported by: lkraav Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4.2
Component: Template Keywords:
Focuses: Cc:


My pre_get_posts action overrides a plugin's query:

$q->set( "page_id", icl_object_id( get_option( "mp_store_page" ), "page", true ) );

This causes, among other things:

NOTICE: wp-includes/post-template.php:1270 - Trying to get property of non-object

To me, it looks strange that the function's signature sort of accounts for this scenario, but in the function there's no handling for when it actually happens at

if ( 'page' != $post->post_type )

Change History (3)

#1 @lkraav
3 years ago

Also see #18750 #21790


#0  get_page_template_slug() called at [/home/markitek/public_html/project/wp-includes/template.php:228]
#1  get_page_template() called at [/home/markitek/public_html/project/wp-includes/template-loader.php:31]
#2  require_once(/home/markitek/public_html/project/wp-includes/template-loader.php) called at [/home/markitek/public_html/project/wp-blog-header.php:16]
#3  require(/home/markitek/public_html/project/wp-blog-header.php) called at [/home/markitek/public_html/project/index.php:17]
Last edited 3 years ago by lkraav (previous) (diff)

#2 @SergeyBiryukov
3 years ago

  • Milestone Awaiting Review deleted
  • Status changed from new to closed

Duplicate of #24250.

#3 @SergeyBiryukov
3 years ago

  • Resolution set to duplicate
Note: See TracTickets for help on using tickets.