Title: Small bug found in categories.php
Last modified: August 18, 2016

---

# Small bug found in categories.php

 *  [idahocline](https://wordpress.org/support/users/idahocline/)
 * (@idahocline)
 * [22 years, 3 months ago](https://wordpress.org/support/topic/small-bug-found-in-categoriesphp/)
 * 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)

 *  [Ryan Boren](https://wordpress.org/support/users/ryan/)
 * (@ryan)
 * [22 years, 3 months ago](https://wordpress.org/support/topic/small-bug-found-in-categoriesphp/#post-39789)
 * 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.
 *  Moderator [Matt Mullenweg](https://wordpress.org/support/users/matt/)
 * (@matt)
 * [22 years, 3 months ago](https://wordpress.org/support/topic/small-bug-found-in-categoriesphp/#post-39791)
 * 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.
 *  [Ryan Boren](https://wordpress.org/support/users/ryan/)
 * (@ryan)
 * [22 years, 3 months ago](https://wordpress.org/support/topic/small-bug-found-in-categoriesphp/#post-39800)
 * 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?
 *  Moderator [Matt Mullenweg](https://wordpress.org/support/users/matt/)
 * (@matt)
 * [22 years, 3 months ago](https://wordpress.org/support/topic/small-bug-found-in-categoriesphp/#post-39802)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [Matt Mullenweg](https://wordpress.org/support/users/matt/)
 * Last activity: [22 years, 3 months ago](https://wordpress.org/support/topic/small-bug-found-in-categoriesphp/#post-39802)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
