Changeset 4119

Show
Ignore:
Timestamp:
08/27/06 19:26:03 (2 years ago)
Author:
ryan
Message:

Handle posts with an empty cat list. fixes #3072

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/post.php

    r4117 r4119  
    760760    global $wpdb; 
    761761    // If $post_categories isn't already an array, make it one: 
    762     if (!is_array($post_categories) || 0 == count($post_categories)
     762    if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories)
    763763        $post_categories = array(get_option('default_category')); 
    764764 
     
    795795    if ($add_cats) { 
    796796        foreach ($add_cats as $new_cat) { 
    797             $wpdb->query(" 
    798                 INSERT INTO $wpdb->post2cat (post_id, category_id)  
    799                 VALUES ($post_ID, $new_cat)"); 
     797            if ( !empty($new_cat) ) 
     798                $wpdb->query(" 
     799                    INSERT INTO $wpdb->post2cat (post_id, category_id)  
     800                    VALUES ($post_ID, $new_cat)"); 
    800801        } 
    801802    }