#24250 closed defect (bug) (fixed)
Notice thrown in get_page_template_slug in certain conditions
Reported by: | tollmanz | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | minor | Version: | 3.4 |
Component: | Template | Keywords: | |
Focuses: | Cc: |
Description
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:
- Remove all posts from site (or just trash them)
- Add the test code below to Twenty Thirteen's functions.php (making sure that Twenty Thirteen is activated)
- Load the front page
- 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.
Attachments (1)
Change History (6)
Note: See
TracTickets for help on using
tickets.
The diff file also improves the
$post_id
PHPDoc as it can be null as well as an int.