Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#15008 closed defect (bug) (fixed)

Deleting a category can orphan posts from the term_relationships table

Reported by: blepoxp's profile blepoxp Owned by: blepoxp's profile 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

Attachments (4)

15008.diff (1.2 KB) - added by blepoxp 14 years ago.
if taxonomy is category, send through wp_delete_category wrapper function
15008-2.diff (2.3 KB) - added by blepoxp 14 years ago.
deprecates wp_delete_category
15008-2.2.diff (2.3 KB) - added by blepoxp 14 years ago.
remove (int) cast
15008-4.diff (3.1 KB) - added by blepoxp 14 years ago.
Forgot xmlrpc function…

Download all attachments as: .zip

Change History (16)

@blepoxp
14 years ago

if taxonomy is category, send through wp_delete_category wrapper function

#1 follow-up: @nacin
14 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().

#2 @scribu
14 years ago

  • Description modified (diff)

#3 in reply to: ↑ 1 @scribu
14 years ago

Replying to nacin:

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

+1

@blepoxp
14 years ago

deprecates wp_delete_category

#4 @blepoxp
14 years ago

Updated diff deprecates wp_delete_category and places logic inside wp_delete_term.

@blepoxp
14 years ago

remove (int) cast

#5 @louyx
14 years ago

  • Cc louy08@… added

@blepoxp
14 years ago

Forgot xmlrpc function...

#6 follow-up: @dd32
14 years ago

Can we abstract that functionality out of wp_delete_term() perhaps?

eg, An action fired within wp_delete_term() which has a functon hooked to manage the category weirdness's?

#7 in reply to: ↑ 6 @nacin
14 years ago

Replying to dd32:

Can we abstract that functionality out of wp_delete_term() perhaps?

eg, An action fired within wp_delete_term() which has a functon hooked to manage the category weirdness's?

That should probably be done across the board in #11576 for all CRUD actions, not just delete.

#8 @nacin
14 years ago

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

(In [15690]) Have wp_delete_category wrap wp_delete_term. Move wp_delete_category into wp-includes scope for consistency. fixes #15008, props blepoxp.

#9 @nacin
14 years ago

Decided there wasn't much harm in leaving the function as an undeprecated wrapper. We have quite a few of those in the taxonomy API for tag and category functions wrapping generic term functions.

#10 @blepoxp
14 years ago

Changeset looks like you deleted wp_delete_category w/o adding it back to deprecated.php or taxonomy.php. Am I reading that correctly?

#11 @nacin
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#12 @nacin
14 years ago

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

(In [15712]) Restore wp_delete_category. props blepoxp, fixes #15008.

Note: See TracTickets for help on using tickets.