From 3c12867919487d6e54f3e844b01954338c56a4fe Mon Sep 17 00:00:00 2001 From: Ryan Boren 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: https://develop.svn.wordpress.org/trunk@2873 602fd350-edb4-49c9-b593-d223f7449a82 --- 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] ); }