Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#32533 closed defect (bug) (worksforme)

wp_delete_post() is not deleting "wp_term_relationships"

Reported by: vishalkakadiya's profile vishalkakadiya Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2.2
Component: Taxonomy Keywords: needs-patch reporter-feedback close
Focuses: Cc:


I am working with custom post types and custom taxonomy, recently i need to delete unwanted posts from the database.

I used wp_delete_post() function with the second argument was "true" to delete the post and all the related data to that particular post.

But I found that it is not deleting the data from the "wp_term_relationships" table clearly notice that it is happens with "custom taxonomy" made for the "custom post types".

Change History (6)

#1 @vishalkakadiya
8 years ago

I also forgot to mention that when add any post in "custom post type" assigned any "term" of the "custom taxonomy" to test this issue.

#2 @vishalkakadiya
8 years ago

  • Severity changed from normal to major

#3 @vishalkakadiya
8 years ago

  • Severity changed from major to trivial

#4 @vishalkakadiya
8 years ago

  • Keywords needs-patch added
  • Severity changed from trivial to major

#5 @dd32
8 years ago

  • Keywords reporter-feedback close added
  • Severity changed from major to normal

This sounds like the Custom Taxonomies were not registered at the time of deletion, or not attached to the post type correctly.

wp_delete_post() calls wp_delete_object_term_relationships($postid, get_object_taxonomies($post->post_type)); as part of it's deletion process.

Changing this behaviour is not really possible at present, as we do not store the object-type in the term_relationships table. We have no idea if TaxA + Object123 is Post 123 or User 123 if TaxA is not attached to the post_type.

Can you duplicate the issue you saw? Can you confirm that the taxomies were registered at that time?

#6 @wonderboymusic
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Thanks for the ticket, vishalkakadiya. Closing due to no feedback. Let us know if you find any other issues, we're happy to take a look.

Note: See TracTickets for help on using tickets.