[wp-trac] [WordPress Trac] #25334: With custom page templates set per page, surprising behavior after switching themes

WordPress Trac noreply at wordpress.org
Mon Sep 16 19:20:01 UTC 2013


#25334: With custom page templates set per page, surprising behavior after
switching themes
----------------------------+-----------------------------
 Reporter:  ericlewis       |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  trunk
 Severity:  normal          |   Keywords:  dev-feedback
----------------------------+-----------------------------
 If you have custom page templates set for a page, and you switch to a new
 theme that has no custom templates, bizarre behavior ensues.

 When editing one of these pages, upon saving, everything looks fine. But
 actually, there was is a silent failure around post.php:2903:

 {{{
 if ( !empty($page_template) && 'page' == $data['post_type'] ) {
                 $post->page_template = $page_template;
                 $page_templates = wp_get_theme()->get_page_templates();
                 if ( 'default' != $page_template && ! isset(
 $page_templates[ $page_template ] ) ) {
                         if ( $wp_error )
                                 return new
 WP_Error('invalid_page_template', __('The page template is invalid.'));
                         else
                                 return 0;
                 }
                 update_post_meta($post_ID, '_wp_page_template',
 $page_template);
         }
 }}}

 Since the page template is still set for this page, but does not exist in
 the theme, the function returns early, which means we don't hit a few
 crucial hooks - edit_post, save_post, and wp_insert_post.

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


More information about the wp-trac mailing list