Make WordPress Core

Ticket #13318: 13318.get-terms-custom-arg-3.diff

File 13318.get-terms-custom-arg-3.diff, 1.9 KB (added by mfields, 14 years ago)

Builds off previous diff. unset custom_cache_key before serialization.

  • wp-includes/taxonomy.php

     
    11291129 * The 'parent' argument is different from 'child_of' in that a term X is considered a 'parent'
    11301130 * of term Y only if term X is the father of term Y, not its grandfather or great-grandfather, etc.
    11311131 *
     1132 * The 'custom_cache_key' argument, if set to true, will use all arguments passed in $args to
     1133 * generate the cache key. Only recognized arguments will be used if it is set to false.
     1134 * Its default value is false.
     1135 *
    11321136 * @package WordPress
    11331137 * @subpackage Taxonomy
    11341138 * @since 2.3.0
     
    11611165                'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(),
    11621166                'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
    11631167                'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
    1164                 'pad_counts' => false, 'offset' => '', 'search' => '');
     1168                'pad_counts' => false, 'offset' => '', 'search' => '', 'custom_cache_key' => false );
    11651169        $args = wp_parse_args( $args, $defaults );
    11661170        $args['number'] = absint( $args['number'] );
    11671171        $args['offset'] = absint( $args['offset'] );
     
    11951199                        return $empty_array;
    11961200        }
    11971201
    1198         // $args can be whatever, only use the args defined in defaults to compute the key
     1202        $prefix = ( $args['custom_cache_key'] ) ? $args : $defaults;
     1203        unset( $prefix['custom_cache_key'] );
    11991204        $filter_key = ( has_filter('list_terms_exclusions') ) ? serialize($GLOBALS['wp_filter']['list_terms_exclusions']) : '';
    1200         $key = md5( serialize( compact(array_keys($defaults)) ) . serialize( $taxonomies ) . $filter_key );
     1205        $key = md5( serialize( compact( array_keys( $prefix ) ) ) . serialize( $taxonomies ) . $filter_key );
    12011206        $last_changed = wp_cache_get('last_changed', 'terms');
    12021207        if ( !$last_changed ) {
    12031208                $last_changed = time();