[wp-trac] [WordPress Trac] #24250: Notice thrown in get_page_template_slug in certain conditions

WordPress Trac noreply at wordpress.org
Thu May 2 17:18:32 UTC 2013


#24250: Notice thrown in get_page_template_slug in certain conditions
--------------------------+-----------------------------
 Reporter:  tollmanz      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Template      |    Version:  3.4
 Severity:  minor         |   Keywords:
--------------------------+-----------------------------
 When `get_page_template_slug()` is called outside of the loop and
 `get_post` returns `null`, the check of `$post->post_type` will trigger
 the notice:

 > Notice: Trying to get property of non-object in /path/to/root/wp-
 includes/post-template.php on line 1284

 Steps to reproduce:

 1. Remove all posts from site (or just trash them)
 2. Add the test code below to Twenty Thirteen's functions.php (making sure
 that Twenty Thirteen is activated)
 3. Load the front page
 4. Notice will appear

 {{{
 function test_get_page_template_slug() {
         get_page_template_slug();
 }
 add_action( 'init', 'test_get_page_template_slug' );
 }}}

 I'm marking as 3.4 since `get_page_template_slug()` was introduced then.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/24250>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list