Ticket #2609 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Set posts of deleted category on the default category

Reported by: santana Assigned to: westi
Priority: normal Milestone: 2.1
Component: Administration Version: 2.0.2
Severity: normal Keywords: Delete category bg|has-patch
Cc:

Description

Wordpress allow to set default category in "Options MenĂ¹". In "Manage Categories" menĂ¹ it is written "Deleting a category does not delete posts from that category, it will just set them back to the default category <my_default_category>" but if I delete a category, posts of that category are set on category with ID = 1, Uncategorized Category. This category may not be the default cateroty.


If I can afford, I think that files involved in are:

1- /wordpress/wp-admin/admin-db.php 2- /wordpress/wp-admin/categories.php

I have fixed this problem in this way (lines with "<" are removed, with ">" are added, with "--" are unmodified) :

--- File categories.php --- [around line 47]


< if (1 == $cat_ID)

> if (get_cat_ID(get_catname(get_option('default_category'))) == $cat_ID)
--   die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));

--- File admin-db.php --- [around line 169 - in wp_delete_category function]



>    $cat_def = get_cat_ID(get_catname(get_option('default_category')));

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


MY PLATFORM: - O.S.: Debian Testing GNU/Linux - Kernel 2.6.15.4 - PHP v. 4; - MySql? v. 4.1; - Web Sever: Apache v. 1.3;

Attachments

2609.diff (0.7 kB) - added by westi on 03/31/06 17:10:29.
Patch to ensure we don't attempt to delete the default cats

Change History

03/30/06 17:41:58 changed by westi

  • owner changed from anonymous to westi.
  • status changed from new to assigned.
  • severity changed from critical to major.
  • milestone set to 2.1.

I think trunk already does some of this looking at the trunk admin-db.php

The first change is definetly needed though.

I'll whip up a patch.

03/31/06 17:10:29 changed by westi

  • attachment 2609.diff added.

Patch to ensure we don't attempt to delete the default cats

03/31/06 17:21:20 changed by westi

  • keywords changed from Delete category to Delete category bg|has-patch.
  • severity changed from major to normal.

Attached patch should fix this for categories.php

This is belt and braces stuff as we should never be called with the default cats as they don't get an enabled delete link on the UI.

The admin-db.php stuff in wp_delete_category.php looks fine on trunk.

04/01/06 23:27:49 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [3675]) Add braces in case our belt gives out after a large meal. Props westi. fixes #2609