Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 18698)
+++ wp-includes/post.php	(working copy)
@@ -2554,8 +2554,49 @@
 	// expected_slashed (everything!)
 	$data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
 	$data = apply_filters('wp_insert_post_data', $data, $postarr);
+	if ( is_wp_error ( $data ) ) {
+		if ( $wp_error )
+			return $data;
+		else
+			return 0;
+	}
 	$data = stripslashes_deep( $data );
 	$where = array( 'ID' => $post_ID );
+	
+	// categories
+	$post_category = apply_filters( 'wp_insert_post_category', $post_category );
+	if ( is_wp_error ( $post_category ) ) {
+		if ( $wp_error )
+			return $post_category;
+		else
+			return 0;
+	}
+	// make sure we set a valid category
+	if ( empty( $post_category ) || 0 == count( $post_category ) || !is_array( $post_category ) ) {
+		// 'post' requires at least one category.
+		if ( 'post' == $post_type && 'auto-draft' != $post_status )
+			$post_category = array( get_option( 'default_category' ) );
+		else
+			$post_category = array();
+	}
+	// old-style tags_input
+	if ( !empty( $tags_input ) ) {
+		$tags_input = apply_filters( 'wp_insert_post_tags', $tags_input );
+	}
+	if ( is_wp_error ( $tags_input ) ) {
+		if ( $wp_error )
+			return $tags_input;
+		else
+			return 0;
+	}
+	// new-style support for all tag-like taxonomies
+	$tax_input = apply_filters( 'wp_insert_post_tax', empty( $tax_input ) ? array() : $tax_input );
+	if ( is_wp_error ( $tax_input ) ) {
+		if ( $wp_error )
+			return $tax_input;
+		else
+			return 0;
+	}
 
 	if ( $update ) {
 		do_action( 'pre_post_update', $post_ID );
