From 4b9c67c8763554b4ccc2ed18171fede663c59402 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Sat, 1 Jan 2005 23:13:38 +0000 Subject: [PATCH] When deleting a page level up all children. git-svn-id: http://svn.automattic.com/wordpress/trunk@2030 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions-post.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 5bce65b76b..665fce6af0 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -194,19 +194,23 @@ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array( function wp_delete_post($postid = 0) { global $wpdb; + $postid = (int) $postid; - $result = $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid"); + if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") ) + return $post; - if (!$result) - return $result; + if ( 'static' == $post->post_status ) + $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_status = 'static'"); + $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid"); + $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid"); $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid"); $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid"); - return $result; + return $post; } /**** /DB Functions ****/