WordPress.org

Ready to get started?Download WordPress

Forums

Small bug found in categories.php (5 posts)

  1. idahocline
    Member
    Posted 10 years ago #

    Hi,
    I was trying the remove a category when I got an error message saying that it was the default one....Wrong !
    So I investigate and here is my findings :
    $default_category = get_settings('default_category');
    Around line 67 in "categories.php" :

    if (1 == $cat_ID)
    die("Can't delete the $cat_name category: this is the default one");

    instead of

    if ($default_category == $cat_ID)
    die("Can't delete the $cat_name category: this is the default one");

    and few lines below :

    $wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'");

    instead of

    $wpdb->query("UPDATE $tablepost2cat SET category_id='$default_category' WHERE category_id='$cat_ID'");

  2. Ryan Boren
    WordPress Dev
    Posted 10 years ago #

    Hmm, I notice we have both default_category and default_post_category in the DB. We need to pick one to use. Regardless, your patch looks good. We'll get it in.

  3. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    Category #1 is a special category, you can't delete it. You can rename it, but not delete it. The error message should be changed, not the behaviour.

  4. Ryan Boren
    WordPress Dev
    Posted 10 years ago #

    More specifically, if the category being deleted is the current default post category, should we reset the default post category to '1' (or perhaps even the parent category of the category being deleted, if a parent exists)? When we update the post2cat table, should we change the category to '1', the default post category, or the parent of the deleted category?

  5. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    Right now I believe we're doing parent of deleted category, and category 1 if there is no parent. It could go to the default category if there's no parent, the only reason to keep an category with cat_ID = 1 is it's hardcoded in some places in the code. I think requiring a category #1 is much easier than a bunch of complicated and fault-prone checking if there is > 1 category, etc etc. But I suppose if we tracked down every place it was hardcoded we could "fix" that instead.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.