Support » How-To and Troubleshooting » Small bug found in categories.php

Small bug found in categories.php

  • 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'");

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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.

    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.

    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?

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Small bug found in categories.php’ is closed to new replies.
Skip to toolbar