Make WordPress Core

Ticket #9674: post.php.diff

File post.php.diff, 923 bytes (added by jfarthing84, 15 years ago)

Can we please get this or something similar commited?

  • post.php

     
    31443144        // export array as variables
    31453145        extract($object, EXTR_SKIP);
    31463146
    3147         // Make sure we set a valid category
    3148         if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category)) {
    3149                 $post_category = array(get_option('default_category'));
    3150         }
    3151 
    31523147        if ( empty($post_author) )
    31533148                $post_author = $user_ID;
    31543149
    31553150        $post_type = 'attachment';
    31563151        $post_status = 'inherit';
     3152       
     3153        // Make sure we set a valid category.
     3154        if ( !isset($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
     3155                // 'post' requires at least one category.
     3156                if ( 'post' == $post_type )
     3157                        $post_category = array( get_option('default_category') );
     3158                else
     3159                        $post_category = array();
     3160        }       
    31573161
    31583162        // Are we updating or creating?
    31593163        if ( !empty($ID) ) {