WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 12 months ago

#17140 closed defect (bug) (worksforme)

get_terms() after wp_update_term() gives old list

Reported by: mastermind Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: close
Focuses: Cc:

Description

When you call get_terms() after you have modified a term via wp_update_term(), you still get the old list.

Workaround: Call wp_flush_cache() after wp_update_term(). (Obviously, a performance killer.)

Change History (6)

comment:1 scribu3 years ago

  • Keywords close added

The solution would be to not call get_terms() in the same page load.

WP handles it by always doing a redirect after any edit.

comment:2 SergeyBiryukov3 years ago

  • Milestone Awaiting Review deleted
  • Status changed from new to closed

Related: #14485

comment:3 SergeyBiryukov3 years ago

  • Status changed from closed to reopened

Didn't mean to close without a resolution.

Actually, can't reproduce on current trunk:

$category = get_term(1, 'category');
$category->slug = 'uncategorized' . current_time('timestamp');

wp_update_term( $category->term_id, 'category', array( 'slug' => $category->slug ) );

var_dump( $category );
var_dump( get_terms('category') );

get_terms() returns the updated term as well. Looks like fixed in 3.2.

comment:4 SergeyBiryukov3 years ago

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

comment:5 mastermind3 years ago

Thanks for checking. I'm on vacation now, I'll have a look at it when I'm back.

comment:6 SergeyBiryukov12 months ago

  • Component changed from General to Taxonomy

Related: #24189

Note: See TracTickets for help on using tickets.