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
This commit is contained in:
Ryan Boren 2005-09-14 00:34:04 +00:00
parent 8baae0c89e
commit 3c12867919
2 changed files with 28 additions and 7 deletions

View File

@ -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);
}

View File

@ -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] );
}