Make WordPress Core

Ticket #26234: 26234.patch

File 26234.patch, 3.4 KB (added by johnjamesjacoby, 11 years ago)

I can get you a toe by 3 o'clock this afternoon, with nail polish

  • wp-includes/category-template.php

    diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
    index 57f7cb9..258b397 100644
    a b  
    10881088        $terms = get_object_term_cache( $post->ID, $taxonomy );
    10891089        if ( false === $terms ) {
    10901090                $terms = wp_get_object_terms( $post->ID, $taxonomy );
    1091                 wp_cache_add($post->ID, $terms, $taxonomy . '_relationships');
     1091                wp_cache_add($post->ID, $terms, _get_taxonomy_cache_key( $taxonomy ) . '_relationships');
    10921092        }
    10931093
    10941094        $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy );
     
    11271127                $term_links[] = '<a href="' . esc_url( $link ) . '" rel="tag">' . $term->name . '</a>';
    11281128        }
    11291129
    1130         $term_links = apply_filters( "term_links-$taxonomy", $term_links );
     1130        $taxonomy_key = _get_taxonomy_cache_key( $taxonomy );
     1131        $term_links = apply_filters( "term_links-$taxonomy_key", $term_links );
    11311132
    11321133        return $before . join( $sep, $term_links ) . $after;
    11331134}
  • wp-includes/taxonomy.php

    diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
    index 06a9126..06762ec 100644
    a b  
    23172317                                return new WP_Error( 'db_insert_error', __( 'Could not insert term relationship into the database' ), $wpdb->last_error );
    23182318        }
    23192319
    2320         wp_cache_delete( $object_id, $taxonomy . '_relationships' );
     2320        wp_cache_delete( $object_id, _get_taxonomy_cache_key( $taxonomy ) . '_relationships' );
    23212321
    23222322        do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids);
    23232323        return $tt_ids;
     
    28082808 * @return bool|array Empty array if $terms found, but not $taxonomy. False if nothing is in cache for $taxonomy and $id.
    28092809 */
    28102810function get_object_term_cache($id, $taxonomy) {
     2811        $taxonomy = _get_taxonomy_cache_key( $taxonomy );
    28112812        $cache = wp_cache_get($id, "{$taxonomy}_relationships");
    28122813        return $cache;
    28132814}
     
    28442845        $object_ids = array_map('intval', $object_ids);
    28452846
    28462847        $taxonomies = get_object_taxonomies($object_type);
     2848        $taxonomy_key = _get_taxonomy_cache_key( $taxonomies );
    28472849
    28482850        $ids = array();
    28492851        foreach ( (array) $object_ids as $id ) {
    2850                 foreach ( $taxonomies as $taxonomy ) {
    2851                         if ( false === wp_cache_get($id, "{$taxonomy}_relationships") ) {
    2852                                 $ids[] = $id;
    2853                                 break;
    2854                         }
     2852                if ( false === wp_cache_get($id, "{$taxonomy_key}_relationships") ) {
     2853                        $ids[] = $id;
     2854                        break;
    28552855                }
    28562856        }
    28572857
     
    28652865                $object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term;
    28662866
    28672867        foreach ( $ids as $id ) {
    2868                 foreach ( $taxonomies as $taxonomy ) {
    2869                         if ( ! isset($object_terms[$id][$taxonomy]) ) {
    2870                                 if ( !isset($object_terms[$id]) )
    2871                                         $object_terms[$id] = array();
    2872                                 $object_terms[$id][$taxonomy] = array();
    2873                         }
     2868                if ( ! isset($object_terms[$id][$taxonomy_key]) ) {
     2869                        if ( !isset($object_terms[$id]) )
     2870                                $object_terms[$id] = array();
     2871                        $object_terms[$id][$taxonomy_key] = array();
    28742872                }
    28752873        }
    28762874
    28772875        foreach ( $object_terms as $id => $value ) {
    2878                 foreach ( $value as $taxonomy => $terms ) {
    2879                         wp_cache_add( $id, $terms, "{$taxonomy}_relationships" );
    2880                 }
     2876                wp_cache_add( $id, $terms, "{$taxonomy_key}_relationships" );
    28812877        }
    28822878}
    28832879
     
    34583454
    34593455        return $parent;
    34603456}
     3457
     3458function _get_taxonomy_cache_key( $taxonomy = '' ) {
     3459        if ( is_array( $taxonomy ) ) {
     3460                $taxonomy_key = implode( '_', $taxonomy );
     3461        } else {
     3462                $taxonomy_key = $taxonomy;
     3463        }
     3464        return $taxonomy_key;
     3465}
     3466