WordPress.org

Make WordPress Core

Opened 16 years ago

Closed 15 years ago

Last modified 15 years ago

#2789 closed defect (bug) (fixed)

Cannot delete original default categories

Reported by: liquidcool Owned by: westi
Milestone: Priority: normal
Severity: major Version: 2.0.4
Component: Administration Keywords: delete category has-patch
Focuses: Cc:

Description

When trying to delete the default category Uncategorized, I receive a message saying:

Processing data...

but nothing follows. I had set another category (Everything) as the default. I tried to delete a 3rd category, and instead of its contents going to Everything, it went to Uncategorized. Apparently setting the default category ONLY affects the Category checkboxes on the Write Post page. Others have had a similar report trying to delete the Blogroll link category. I have been able to amass evidence from several posts, contained in these threads:

http://wordpress.org/support/topic/3655?replies=4#post-21653
http://wordpress.org/support/topic/65555?replies=4
http://wordpress.org/support/topic/66013?replies=4

While many recommend a workaround, it is basically, "don't do what you're trying to do", and isn't really acceptable. What if you want to transfer posts from one category to another, by deleting one and setting another to the default, as I tried to above? The system behavior (moving posts to the original default of Uncategorized, instead of the current default) is completely contrary to the user messages, leading to data corruption/pollution. The ability to batch modify posts in the admin panel would allow you to correct the damage, but that feature does not exist.

The message that displays the category that posts will be moved to is part of the problem. I have tracked that down that change:

http://trac.wordpress.org/changeset/3672

NOTE: my version is actually 2.0.3, which isn't an option below.

Good luck!

Attachments (4)

2789.diff (877 bytes) - added by westi 16 years ago.
Patch for 2.0.4 to fix this
2789a.diff (1.4 KB) - added by westi 16 years ago.
Improved patch - actually set the posts to the default cat not 1
2789b.diff (2.9 KB) - added by westi 16 years ago.
Also remove delete link for default link category
2789c.diff (1.5 KB) - added by westi 15 years ago.
The missed hunk from 2789b that didn't make it

Download all attachments as: .zip

Change History (18)

#1 @westi
16 years ago

That changeset is on trunk not the 2.0 branch and was never applied to 2.0.3 so cannot be the issue here.

However some of the fixes made on trunk may be missing for 2.0.3 in this area.

#2 @westi
16 years ago

  • Keywords bg|dev-feedback added
  • Milestone set to 2.0.4

I think we need to apply the fix from [3675] in relation to #2609 here so as to ensure we block the deletion of default cats with nice message

#3 @westi
16 years ago

  • Keywords bg|needs-patch added; bg|dev-feedback removed
  • Owner changed from anonymous to westi
  • Status changed from new to assigned

We also need to patch admin-db.php to fix "wp_delete_category" which referrers to cat_ID 1 as the default category still.

That should then fix this for 2.0.4 :-)

I'll knock up a patch later if someone doesn't beat me to it.

@westi
16 years ago

Patch for 2.0.4 to fix this

#4 @westi
16 years ago

  • Keywords bg|has-patch added; bg|needs-patch removed

The attached patch backports the changes from trunk to 2.0.4 for this including the belt and braces in categories.php

#5 @westi
16 years ago

Hmm I'm not sure this patch completely addresses the problems here.

I have just checked my test blog again and the posts have not been moved to the default category :-(

#6 @westi
16 years ago

Yep wp_delete_category is still broken:

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

New patch incoming

@westi
16 years ago

Improved patch - actually set the posts to the default cat not 1

#7 @westi
16 years ago

That new patch should fix it.

Not tested but the bug is obvious ;-)

@westi
16 years ago

Also remove delete link for default link category

#8 @westi
16 years ago

I noticed while fixing #2806 that you can attempt to delete the default link cat too.

Extend this patch to cover that as well.

#9 @ryan
15 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [4032]) Default cat deletion fix from westi. fixes #2789

#10 @war59312
15 years ago

  • Milestone changed from 2.0.4 to 2.1
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 2.0.2 to 2.0.4

This patch does not seem to be 100% .

In Wordpress 2.0.4 you still cant delete the Blogroll Link Category. You do not get an error message and all you see on the screen is "Processing Data..." .

So either you need to display the error saying you can not delete the default category or fix it so you can. I hope you allow the second option in this case. ;)

#11 @ryan
15 years ago

Sounds like we forgot to handle the AJAX route.

@westi
15 years ago

The missed hunk from 2789b that didn't make it

#12 @westi
15 years ago

  • Keywords has-patch added; bg|has-patch removed
  • Milestone changed from 2.1 to 2.0.5

We need to make sure we don't show the delete link for the default cat in 2.0.5

#13 @markjaquith
15 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [4271]) Default cat deletion fix from westi (part 2). fixes #2789

#14 @(none)
15 years ago

  • Milestone 2.0.5 deleted

Milestone 2.0.5 deleted

Note: See TracTickets for help on using tickets.