WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#11166 closed defect (bug) (invalid)

wp_set_object_terms() Deletes All New Tags

Reported by: miqrogroove Owned by: filosofo
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.4
Component: Taxonomy Keywords: needs-patch
Focuses: Cc:

Description

While working on #10543, I noticed a logic flaw in function wp_set_object_terms().

The call to $wpdb->insert() is logically incoherent with the default argument $append = false. Any such occurrence results in the inserted tags being deleted, due to failure to modify the $old_tt_ids array.

Change History (2)

comment:1 @miqrogroove5 years ago

  • Priority changed from high to normal

Sorry, description was not accurate. The problem is actually caused if wp_set_object_terms() is called more than one time. It appears $old_tt_ids is taking a cached value, so if any previous calls to this function added new tags, they will be deleted on any successive calls.

This is probably unlikely to happen in the wild. One possible trigger is if someone writes a custom agent that creates new posts by posting values for both tags_input and tax_input.

comment:2 @miqrogroove5 years ago

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

Sorted, nevermind _

Note: See TracTickets for help on using tickets.