Make WordPress Core

Ticket #29894: taxonomy.php.update3.diff

File taxonomy.php.update3.diff, 1.3 KB (added by webgeekconsulting, 10 years ago)

taxonomy.php patch 3

  • wp-includes/taxonomy.php

     
    15551555
    15561556        $query = "SELECT $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits";
    15571557
     1558        // $args can be whatever, only use the args defined in defaults to compute the key
     1559        $filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
     1560        $key = md5( $query . $filter_key );
     1561        $last_changed = wp_cache_get( 'last_changed', 'terms' );
     1562        if ( ! $last_changed ) {
     1563                $last_changed = microtime();
     1564                wp_cache_set( 'last_changed', $last_changed, 'terms' );
     1565        }
     1566        $cache_key = "get_terms:$key:$last_changed";
     1567        $cache = wp_cache_get( $cache_key, 'terms' );
     1568        if ( false !== $cache ) {
     1569
     1570                /**
     1571                 * Filter the given taxonomy's terms cache.
     1572                 *
     1573                 * @since 2.3.0
     1574                 *
     1575                 * @param array        $cache      Cached array of terms for the given taxonomy.
     1576                 * @param string|array $taxonomies A taxonomy or array of taxonomies.
     1577                 * @param array        $args       An array of arguments to get terms.
     1578                 */
     1579                $cache = apply_filters( 'get_terms', $cache, $taxonomies, $args );
     1580                return $cache;
     1581        }
     1582
    15581583        if ( 'count' == $_fields ) {
    15591584                $term_count = $wpdb->get_var($query);
    15601585                return $term_count;