WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/27/2010 07:42:23 PM (12 years ago)
Author:
ryan
Message:

Change back to an option so that it is always there and regenerate it after cleaning the cache instead of waiting for the next page load. Don't clean taxonomy wide caches when just updating object counts to avoid cleaning when updating a post.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r12834 r12881  
    18681868    }
    18691869
    1870     clean_term_cache($terms);
     1870    clean_term_cache($terms, '', false);
    18711871
    18721872    return true;
     
    19181918 * @param int|array $ids Single or list of Term IDs
    19191919 * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context.
    1920  */
    1921 function clean_term_cache($ids, $taxonomy = '') {
     1920 * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.
     1921 */
     1922function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {
    19221923    global $wpdb;
    19231924    static $cleaned = array();
     
    19521953            continue;
    19531954        $cleaned[$taxonomy] = true;
    1954         wp_cache_delete('all_ids', $taxonomy);
    1955         wp_cache_delete('get', $taxonomy);
    1956         delete_transient("{$taxonomy}_children");
     1955
     1956        if ( $clean_taxonomy ) {
     1957            wp_cache_delete('all_ids', $taxonomy);
     1958            wp_cache_delete('get', $taxonomy);
     1959            delete_option("{$taxonomy}_children");
     1960            // Regenerate {$taxonomy}_children
     1961            _get_term_hierarchy($taxonomy);
     1962        }
     1963
    19571964        do_action('clean_term_cache', $ids, $taxonomy);
    19581965    }
     
    20932100    if ( !is_taxonomy_hierarchical($taxonomy) )
    20942101        return array();
    2095     $children = get_transient("{$taxonomy}_children");
     2102    $children = get_option("{$taxonomy}_children");
     2103
    20962104    if ( is_array($children) )
    20972105        return $children;
    2098 
    20992106    $children = array();
    21002107    $terms = get_terms($taxonomy, array('get' => 'all', 'orderby' => 'id', 'fields' => 'id=>parent'));
     
    21032110            $children[$parent][] = $term_id;
    21042111    }
    2105     set_transient("{$taxonomy}_children", $children);
     2112    update_option("{$taxonomy}_children", $children);
    21062113
    21072114    return $children;
Note: See TracChangeset for help on using the changeset viewer.