WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#11530 closed defect (bug) (fixed)

logic errors in clean_term_cache()

Reported by: Denis-de-Bernardy Owned by: westi
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description (last modified by westi)

clean_term_cache() has a completely random behaviour.

the attached patch ensures that it behaves consistently.

Attachments (1)

11530.diff (1.4 KB) - added by Denis-de-Bernardy 8 years ago.

Download all attachments as: .zip

Change History (10)

#2 @westi
8 years ago

  • Description modified (diff)
  • Owner changed from filosofo to westi
  • Status changed from new to accepted

Have you got some example plugin code we can use to test this and reproduce the issue so that more people can test the fix?

#3 @dd32
8 years ago

Can you also explain which part is the Complelely random section? I'm guessing its the Action args?

Also, What was the point of this over the original, It doesnt add anything extra..

$taxonomies = array($taxonomy); 
foreach ( $taxonomies as $taxonomy ) { 
 	foreach ( $ids as $id ) { 
 	   wp_cache_delete($id, $taxonomy); 
 	} 
} 

#4 @Denis-de-Bernardy
8 years ago

@westi: no working example, I merely ran into it while looking into improving a flush() function for memcached. please look at the code as it currently is.

the clean_terms_cache() accepts term_ids or term_taxonomy_ids as the first argument, and a taxonomy or an array of taxonomies as the second argument. use cases:

  1. one taxonomy provided, array of t_ids given. it does exactly what it should, i.e. deletes the cache properly, and ends up calling:
do_action('clean_term_cache', $t_ids, $taxonomy);
  1. no taxonomy provided, array of tt_ids given. it deletes the cache properly, but ends up calling the clean_term_cache action with tt_ids:
do_action('clean_term_cache', $tt_ids, $last_taxonomy_looped);
  1. multiple taxonomies provided, array of t_ids given. then this deletes nothing (it's an invalid bucket):
wp_cache_delete($id, $taxonomy);

and the concluding do_action amounts to:

do_action('clean_term_cache', $t_ids, $last_taxonomy_looped);

#5 @ryan
8 years ago

Patch looks good to me.

#6 @ryan
8 years ago

(In [12510]) Cleanup clean_term_cache(). Props Denis-de-Bernardy. see #11530

#7 @westi
8 years ago

  • Milestone changed from 2.9.1 to 3.0

Setting the milestone to 3.0 for now as that is where the changes so far have been committed.

#8 @hakre
8 years ago

In my eyes it looks like that the patch was comitted but the ticket is still open. How to continue? Close the ticket? Keep it open?

#9 @Denis-de-Bernardy
8 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed
Note: See TracTickets for help on using tickets.