Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#34338 closed defect (bug) (fixed)

wp_remove_object_terms() should call wp_cache_delete() like wp_set_object_terms()

Reported by: tszming's profile tszming Owned by: boonebgorges's profile boonebgorges
Milestone: 4.4 Priority: normal
Severity: normal Version: 3.6
Component: Taxonomy Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

If you call get_the_terms() after wp_remove_object_terms(), cached terms will be returned.

Failed:

wp_remove_object_terms($id, 'test', 'mycategory');
$terms = get_the_terms($id, 'mycategory');

Ok:

wp_set_object_terms($id, null, 'mycategory');
$terms = get_the_terms($id, 'mycategory');

wp_cache_delete() need to be place inside the wp_remove_object_terms() like wp_remove_object_terms()

Attachments (2)

Test_34338.php (601 bytes) - added by tszming 9 years ago.
Test
taxonomy.diff (588 bytes) - added by tszming 9 years ago.
Patch

Download all attachments as: .zip

Change History (6)

#1 @swissspidy
9 years ago

  • Component changed from General to Taxonomy
  • Keywords needs-patch needs-unit-tests added
  • Version changed from 4.3.1 to 3.6

@tszming
9 years ago

Test

@tszming
9 years ago

Patch

#2 @swissspidy
9 years ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

@boonebgorges Since you're a component maintainer, would you mind having a look at this?

#3 @boonebgorges
9 years ago

  • Milestone changed from Awaiting Review to 4.4

Thanks for the ticket and the patch, tszming!

#4 @boonebgorges
9 years ago

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

In 35268:

Bust object term cache in wp_remove_object_terms().

Props tszming.
Fixes #34338.

Note: See TracTickets for help on using tickets.