Ticket #20462: post-category-nonsense.diff

File post-category-nonsense.diff, 1.2 KB (added by wonderboymusic, 8 months ago)
  • wp-includes/post.php

     
    28112811                $postarr = add_magic_quotes($postarr); 
    28122812        } 
    28132813 
    2814         // First, get all of the original fields 
    2815         $post = get_post($postarr['ID'], ARRAY_A); 
     2814        $post = array(); 
     2815        if ( ! empty( $postarr['ID'] ) ) { 
     2816                // First, get all of the original fields 
     2817                $post = get_post($postarr['ID'], ARRAY_A); 
    28162818 
    2817         // Escape data pulled from DB. 
    2818         $post = add_magic_quotes($post); 
     2819                // Escape data pulled from DB. 
     2820                $post = add_magic_quotes($post);                 
     2821        } 
    28192822 
    28202823        // Passed post category list overwrites existing category list if not empty. 
    2821         if ( isset($postarr['post_category']) && is_array($postarr['post_category']) 
    2822                          && 0 != count($postarr['post_category']) ) 
    2823                 $post_cats = $postarr['post_category']; 
    2824         else 
    2825                 $post_cats = $post['post_category']; 
     2824        $post_cats = empty( $post['post_category'] ) ? array() : (array) $post['post_category']; 
    28262825 
    28272826        // Drafts shouldn't be assigned a date unless explicitly done so by the user 
    28282827        if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&