From 15b1452d549d8e0712a9affeda97b7891b871c9d Mon Sep 17 00:00:00 2001 From: ryan 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: http://svn.automattic.com/wordpress/trunk@4026 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 c89c5527f..90077076b 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()) {