Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#17140 closed defect (bug) (worksforme)

get_terms() after wp_update_term() gives old list

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


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)

#1 @scribu
13 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.

#2 @SergeyBiryukov
13 years ago

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

Related: #14485

#3 @SergeyBiryukov
13 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.

#4 @SergeyBiryukov
13 years ago

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

#5 @mastermind
13 years ago

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

#6 @SergeyBiryukov
11 years ago

  • Component changed from General to Taxonomy

Related: #24189

Note: See TracTickets for help on using tickets.