Make WordPress Core


Ignore:
Timestamp:
08/27/2006 07:26:03 PM (18 years ago)
Author:
ryan
Message:

Handle posts with an empty cat list. fixes #3072

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.