WordPress.org

Make WordPress Core

Changeset 11140


Ignore:
Timestamp:
04/30/2009 04:51:45 PM (9 years ago)
Author:
ryan
Message:

Fix category search pagination. Fix caching of empty term results. Props Denis-de-Bernardy. fixes #8632

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/categories.php

    r11103 r11140  
    167167$cats_per_page = apply_filters('edit_categories_per_page', $cats_per_page);
    168168
     169if ( !empty($_GET['s']) )
     170    $num_cats = count(get_categories(array('hide_empty' => 0, 'search' => $_GET['s'])));
     171else
     172    $num_cats = wp_count_terms('category');
     173
    169174$page_links = paginate_links( array(
    170175    'base' => add_query_arg( 'pagenum', '%#%' ),
     
    172177    'prev_text' => __('«'),
    173178    'next_text' => __('»'),
    174     'total' => ceil(wp_count_terms('category') / $cats_per_page),
     179    'total' => ceil($num_cats / $cats_per_page),
    175180    'current' => $pagenum
    176181));
  • trunk/wp-includes/taxonomy.php

    r11129 r11140  
    663663    }
    664664    $cache_key = "get_terms:$key:$last_changed";
    665 
    666     if ( $cache = wp_cache_get( $cache_key, 'terms' ) ) {
    667         $terms = apply_filters('get_terms', $cache, $taxonomies, $args);
    668         return $terms;
     665    $cache = wp_cache_get( $cache_key, 'terms' );
     666    if ( false !== $cache ) {
     667        $cache = apply_filters('get_terms', $cache, $taxonomies, $args);
     668        return $cache;
    669669    }
    670670
     
    781781
    782782    if ( empty($terms) ) {
    783         $cache[ $key ] = array();
    784         wp_cache_set( 'get_terms', $cache, 'terms' );
     783        wp_cache_add( $cache_key, array(), 'terms' );
    785784        $terms = apply_filters('get_terms', array(), $taxonomies, $args);
    786785        return $terms;
Note: See TracChangeset for help on using the changeset viewer.