From 85521775208ca1647f9714514dc302dedb916377 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 14 Sep 2005 00:34:04 +0000 Subject: [PATCH] Add clean_post_cache() and clean_page_cache(). Reset GUID when transitioning from draft to publish. fixes #1257 git-svn-id: http://svn.automattic.com/wordpress/trunk@2873 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-post.php | 18 +++++++++++------- wp-includes/functions.php | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index b0167ddae4..824cf30394 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -134,20 +134,24 @@ function wp_insert_post($postarr = array()) { } $result = $wpdb->query($postquery); - if ( $update ) - $rval = $wpdb->rows_affected; - else - $rval = $wpdb->insert_id; + + wp_set_post_cats('', $post_ID, $post_category); + + if ( 'static' == $post_status ) + clean_page_cache($post_ID); + else + clean_post_cache($post_ID); // Set GUID if ( ! $update ) $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'"); - - wp_set_post_cats('', $post_ID, $post_category); if ( $update) { - if ($previous_status != 'publish' && $post_status == 'publish') + if ($previous_status != 'publish' && $post_status == 'publish') { + // Reset GUID if transitioning to publish. + $wpdb->query("UPDATE $wpdb->posts SET guid = '" . get_permalink($post_ID) . "' WHERE ID = '$post_ID'"); do_action('private_to_published', $post_ID); + } do_action('edit_post', $post_ID); } diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 47df6c389e..0076239414 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1167,6 +1167,13 @@ function update_post_cache(&$posts) { } } +function clean_post_cache($id) { + global $post_cache; + + if ( isset( $post_cache[$id] ) ) + unset( $post_cache[$id] ); +} + function update_page_cache(&$pages) { global $page_cache; @@ -1178,6 +1185,14 @@ function update_page_cache(&$pages) { } } + +function clean_page_cache($id) { + global $page_cache; + + if ( isset( $page_cache[$id] ) ) + unset( $page_cache[$id] ); +} + function update_post_category_cache($post_ids) { global $wpdb, $category_cache, $cache_categories; @@ -1264,6 +1279,8 @@ function update_category_cache() { } function clean_user_cache($id) { + global $cache_userdata; + if ( isset( $cache_userdata[$id] ) ) unset( $cache_userdata[$id] ); }