From aa26b4c1a0cbc644ea5765f0084e0193c04f4b13 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 1 Jan 2015 20:35:30 +0000 Subject: [PATCH] If you set `'_wp_page_template'` for a post, and then switch to a theme that doesn't support the template, subsequent calls to `wp_insert_post()` will bail early without running a plethora of hooks. This shouldn't happen. We should set the template to `'default'` and continue through the rest of the function. The function will still bail if `$wp_error` is `true` via `wp_insert_post( $arr, true )`. Props nofearinc. Fixes #25334. Built from https://develop.svn.wordpress.org/trunk@31020 git-svn-id: http://core.svn.wordpress.org/trunk@31001 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 6 +++--- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index d8c8c55542..49ca9e243e 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3423,11 +3423,11 @@ function wp_insert_post( $postarr, $wp_error = false ) { if ( 'default' != $postarr['page_template'] && ! isset( $page_templates[ $postarr['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', 'default' ); + } else { + update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] ); } - update_post_meta( $post_ID, '_wp_page_template', $postarr['page_template'] ); } if ( 'attachment' !== $postarr['post_type'] ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 3150403d0e..8368407749 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31019'; +$wp_version = '4.2-alpha-31020'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.