From 9cd312063255bb8d071ec59ac84fb3206a3f6392 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 22 Jul 2006 04:17:41 +0000 Subject: [PATCH] Rework wp_publish_post(). Should avoid running filters when changing from future to publish. git-svn-id: https://develop.svn.wordpress.org/trunk@4026 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index c89c5527fd..90077076b4 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -652,22 +652,7 @@ function wp_insert_post($postarr = array()) { } if ($post_status == 'publish' && $post_type == 'post') { - do_action('publish_post', $post_ID); - - if ( !defined('WP_IMPORTING') ) { - if ( $post_pingback ) - $result = $wpdb->query(" - INSERT INTO $wpdb->postmeta - (post_id,meta_key,meta_value) - VALUES ('$post_ID','_pingme','1') - "); - $result = $wpdb->query(" - INSERT INTO $wpdb->postmeta - (post_id,meta_key,meta_value) - VALUES ('$post_ID','_encloseme','1') - "); - wp_schedule_single_event(time(), 'do_pings'); - } + wp_publish_post($post_ID); } else if ($post_type == 'page') { wp_cache_delete('all_page_ids', 'pages'); $wp_rewrite->flush_rules(); @@ -736,10 +721,29 @@ function wp_publish_post($post_id) { if ( empty($post) ) return; - if ( 'publish' == $post->post_status ) + if ( 'publish' != $post->post_status ) + $wpdb->query("UPDATE IGNORE $wpdb->posts SET post_status = 'publish' WHERE ID = $post_id"); + + do_action('publish_post', $post_id); + + if ( defined('WP_IMPORTING') ) return; - return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id)); + $post_pingback = get_option('default_pingback_flag'); + if ( $post_pingback ) + $result = $wpdb->query(" + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','_pingme','1') + "); + + $result = $wpdb->query(" + INSERT INTO $wpdb->postmeta + (post_id,meta_key,meta_value) + VALUES ('$post_ID','_encloseme','1') + "); + + wp_schedule_single_event(time(), 'do_pings'); } function wp_set_post_categories($post_ID = 0, $post_categories = array()) {