WordPress.org

Make WordPress Core

Changeset 6286


Ignore:
Timestamp:
10/23/2007 08:33:50 PM (11 years ago)
Author:
ryan
Message:

Separate taxonomy relationships into separate cache buckets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r6285 r6286  
    14301430 */
    14311431function &get_object_term_cache($id, $taxonomy) {
    1432     $terms = wp_cache_get($id, 'object_terms');
    1433     if ( false !== $terms ) {
    1434         if ( isset($terms[$taxonomy]) )
    1435             return $terms[$taxonomy];
    1436         else
    1437             return array();
    1438     }
    1439 
    1440     return false;
     1432    return wp_cache_get($id, "{$taxonomy}_relationships");
    14411433}
    14421434
     
    14661458    $object_ids = array_map('intval', $object_ids);
    14671459
     1460    $taxonomies = get_object_taxonomies($object_type);
     1461
    14681462    $ids = array();
    14691463    foreach ( (array) $object_ids as $id ) {
    1470         if ( false === wp_cache_get($id, 'object_terms') )
    1471             $ids[] = $id;
     1464        foreach ( $taxonomies as $taxonomy ) {
     1465            if ( false === wp_cache_get($id, "{$taxonomy}_relationships") ) {
     1466                $ids[] = $id;
     1467                break;
     1468            }
     1469        }
    14721470    }
    14731471
     
    14751473        return false;
    14761474
    1477     $terms = wp_get_object_terms($ids, get_object_taxonomies($object_type), 'fields=all_with_object_id');
     1475    $terms = wp_get_object_terms($ids, $taxonomies, 'fields=all_with_object_id');
    14781476
    14791477    $object_terms = array();
     
    14821480
    14831481    foreach ( $ids as $id ) {
    1484         if ( ! isset($object_terms[$id]) )
    1485                 $object_terms[$id] = array();
    1486     }
    1487 
    1488     foreach ( $object_terms as $id => $value )
    1489         wp_cache_set($id, $value, 'object_terms');
     1482        foreach ( $taxonomies  as $taxonomy ) {
     1483            if ( ! isset($object_terms[$id][$taxonomy]) ) {
     1484                if ( !isset($object_terms[$id]) )
     1485                    $object_terms[$id] = array();
     1486                $object_terms[$id][$taxonomy] = array();
     1487            }
     1488        }
     1489    }
     1490
     1491    foreach ( $object_terms as $id => $value ) {
     1492        foreach ( $value as $taxonomy => $terms ) {
     1493            wp_cache_set($id, $terms, "{$taxonomy}_relationships");
     1494        }
     1495    }
    14901496}
    14911497
Note: See TracChangeset for help on using the changeset viewer.