[wp-trac] [WordPress Trac] #14399: get_term_children doesn't call clean_term_cache() if necessary
WordPress Trac
wp-trac at lists.automattic.com
Tue Aug 24 09:17:49 UTC 2010
#14399: get_term_children doesn't call clean_term_cache() if necessary
--------------------------+-------------------------------------------------
Reporter: miradev | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 3.0
Severity: normal | Resolution:
Keywords: needs-patch |
--------------------------+-------------------------------------------------
Comment(by miradev):
@scribu
4 weeks languishing here, I thought I was just being a numpty :p
It still doesn't actually work, clean_term_cache() needs to be called
somewhere other than in the same init hook that the taxonomy is
registered. At best I get it to work by calling it in a subsequent
request.
@hakre
I posted on the forums, trying to get some feedback:
http://wordpress.org/support/topic/create-hiearchical-taxonomy-
terms?replies=1
I'll copy the complete example here:
{{{
add_action( 'init', 'create_user_location_tax', 0 );
function create_user_location_tax(){
global $wpdb;
register_taxonomy( 'location', 'users', array('hierarchical' => true,
'show_ui' => true, 'query_var' => true, 'label' => __('Where are you')) );
$dummycountry = 'USA';
$dummystate = 'KENTUCKY';
if( taxonomy_exists('location') ){
$tax_location_terms = get_terms( 'location',
'get=all&hide_empty=false');
if( count($tax_location_terms) < 1 ){
$tax_country = wp_insert_term($dummycountry, 'location');
$parent = $tax_country['term_id'];
$tax_state = wp_insert_term($dummystate, 'location',
array('parent'=>$parent));
clean_term_cache(array($parent), 'location'); // Doesn't do
anything.
}
}
$sql = "SELECT option_value FROM $wpdb->options WHERE option_name =
'location_children'";
$result = $wpdb->get_col($sql);
error_log('term cache: '.$result[0]);
}
}}}
From there, I am a little lost as to what is happening in the WP guts to
figure out why it isn't working. My vague feeling was that all the things
I tried were hitting cached results (for that particular http request).
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14399#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list