From 0b37bd0b6de09d1b1d5ffb03fbdc30eb113e19a1 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 19 Nov 2010 17:09:21 +0000 Subject: [PATCH] Populate post term relationship cache in get_the_terms(). Restores caching lost when we moved away from get_the_category(). see #15407 git-svn-id: http://svn.automattic.com/wordpress/trunk@16487 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/canonical.php | 2 ++ wp-includes/category-template.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index ff36937914..6817b0fd74 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -168,8 +168,10 @@ function redirect_canonical($requested_url=null, $do_redirect=true) { if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=.. parse_str($tax_url['query'], $query_vars); $redirect['query'] = add_query_arg($query_vars, $redirect['query']); + error_log('ugly redir'); } else { // Taxonomy is accessable via a "pretty-URL" $redirect['path'] = $tax_url['path']; + error_log('pretty redir'); } } } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) { diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index d491a6ceda..9aae78eecb 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -1066,9 +1066,11 @@ function get_the_terms( $id = 0, $taxonomy ) { } $terms = get_object_term_cache( $id, $taxonomy ); - if ( false === $terms ) + if ( false === $terms ) { $terms = wp_get_object_terms( $id, $taxonomy ); - + wp_cache_add($id, $terms, $taxonomy . '_relationships'); + } + $terms = apply_filters( 'get_the_terms', $terms, $id, $taxonomy ); if ( empty( $terms ) )