WordPress.org

Make WordPress Core

Ticket #19954: 19954.patch

File 19954.patch, 1.0 KB (added by markoheijnen, 3 years ago)

Does fix the issue. Maybe need better formating

  • wp-includes/post.php

     
    24662466        // Make sure we set a valid category. 
    24672467        if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) { 
    24682468                // 'post' requires at least one category. 
    2469                 if ( 'post' == $post_type && 'auto-draft' != $post_status ) 
     2469                if( 'post' == $post_type && 'auto-draft' != $post_status && ( !isset( $ID ) || ! has_category( '', get_post( $ID ) ) ) ) 
    24702470                        $post_category = array( get_option('default_category') ); 
    24712471                else 
    24722472                        $post_category = array(); 
     
    26092609                $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where ); 
    26102610        } 
    26112611 
    2612         if ( is_object_in_taxonomy($post_type, 'category') ) 
     2612        if ( is_object_in_taxonomy($post_type, 'category') && !empty( $post_category ) ) 
    26132613                wp_set_post_categories( $post_ID, $post_category ); 
    26142614 
    26152615        if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )