From 77838c2433a5e62cf8b972d7761a29d6852d8a18 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 2 Nov 2007 04:31:44 +0000 Subject: [PATCH] Cache get_terms queries that return nothing. git-svn-id: https://develop.svn.wordpress.org/trunk@6307 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 173bf9841e..8323cf0b64 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -640,8 +640,11 @@ function &get_terms($taxonomies, $args = '') { $terms = $wpdb->get_col($query); } - if ( empty($terms) ) - return array(); + if ( empty($terms) ) { + $cache[ $key ] = array(); + wp_cache_set( 'get_terms', $cache, 'terms' ); + return apply_filters('get_terms', array(), $taxonomies, $args); + } if ( $child_of || $hierarchical ) { $children = _get_term_hierarchy($taxonomies[0]);