From 975dbe9b12f80840739d04f9e94ca47c5a5d56ba Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 27 Dec 2012 15:14:43 +0000 Subject: [PATCH] Revert [21942] and have wp_publish_post() deal with the database directly. clean_post_cache() is now also called directly due to [21943]. fixes #22944 for trunk. Unit tests: [1174/tests]. see #11399. see #21963. git-svn-id: https://develop.svn.wordpress.org/trunk@23206 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 54f17f4159..9562e07e33 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3010,18 +3010,31 @@ function wp_update_post( $postarr = array(), $wp_error = false ) { * Publish a post by transitioning the post status. * * @since 2.1.0 - * @uses wp_update_post() + * @uses $wpdb + * @uses do_action() Calls 'edit_post', 'save_post', and 'wp_insert_post' on post_id and post data. * * @param mixed $post Post ID or object. */ function wp_publish_post( $post ) { + global $wpdb; + if ( ! $post = get_post( $post ) ) return; + if ( 'publish' == $post->post_status ) return; + $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post->ID ) ); + + clean_post_cache( $post->ID ); + + $old_status = $post->post_status; $post->post_status = 'publish'; - wp_update_post( $post ); + wp_transition_post_status( 'publish', $old_status, $post ); + + do_action( 'edit_post', $post->ID, $post ); + do_action( 'save_post', $post->ID, $post ); + do_action( 'wp_insert_post', $post->ID, $post ); } /**