WordPress.org

Make WordPress Core

Ticket #14485: garyc40-14485-revised.patch

File garyc40-14485-revised.patch, 1.5 KB (added by garyc40, 7 years ago)

md5 $last_changed before saving to cache

  • wp-includes/taxonomy.php

     
    20012001
    20022002        $term_id = apply_filters('term_id_filter', $term_id, $tt_id);
    20032003
    2004         clean_term_cache($term_id, $taxonomy);
     2004        $force_clean_taxonomy = ( $parent ) ? true : false;
     2005        clean_term_cache($term_id, $taxonomy, true, $force_clean_taxonomy);
    20052006
    20062007        do_action("created_term", $term_id, $tt_id, $taxonomy);
    20072008        do_action("created_$taxonomy", $term_id, $tt_id);
     
    24412442 * @param string $taxonomy Can be empty and will assume tt_ids, else will use for context.
    24422443 * @param bool $clean_taxonomy Whether to clean taxonomy wide caches (true), or just individual term object caches (false). Default is true.
    24432444 */
    2444 function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) {
     2445function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true, $force_clean_taxonomy = false) {
    24452446        global $wpdb;
    24462447        static $cleaned = array();
    24472448
     
    24712472        }
    24722473
    24732474        foreach ( $taxonomies as $taxonomy ) {
    2474                 if ( isset($cleaned[$taxonomy]) )
     2475                if ( isset($cleaned[$taxonomy]) && ! $force_clean_taxonomy )
    24752476                        continue;
    24762477                $cleaned[$taxonomy] = true;
    24772478
     
    24862487                do_action('clean_term_cache', $ids, $taxonomy);
    24872488        }
    24882489
    2489         wp_cache_set('last_changed', time(), 'terms');
     2490        $last_changed = substr( md5( implode( ',', $ids ) . ':' . time() ), 0, 6 );
     2491        wp_cache_set('last_changed', $last_changed, 'terms');
    24902492}