WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#15008 closed defect (bug)

Deleting a category can orphan posts from the term_relationships table — at Version 2

Reported by: blepoxp Owned by: blepoxp
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch regression
Focuses: Cc:

Description (last modified by scribu)

Steps to reproduce:

1) Create a new category

2) Place a post in only that category

3) Delete that category

4) Observe that post no longer exists in term_relationship table (also causes posts to not appear in edit-posts list when filtered for 'uncategorized').

Cause of problem:
Direct calls to wp_delete_term() bypass logic and args previously populated in wp_delete_category().

Possible solutions:
Add logic from wp_delete_category() above each call for wp_delete_term and pass the args directly to wp_delete_term or conditionally check for taxonomy type and pass to wp_delete_category (a wrap for wp_delete_term) to pick up needed logic.

The attached diff takes approach two and passes to wp_delete_category if 'category' == $taxonomy

Change History (3)

blepoxp4 years ago

if taxonomy is category, send through wp_delete_category wrapper function

comment:1 nacin4 years ago

  • Keywords regression added; dev-feedback removed
  • Milestone changed from Awaiting Review to 3.1
  • Version changed from 3.0.1 to 3.0

I think we should deprecate wp_delete_category() (also being used in XMLRPC) and move the logic into wp_delete_term().

comment:2 scribu4 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.