update_object_term_cache

The timeline below displays how wordpress function update_object_term_cache has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|int[]    $object_ids  Comma-separated list or array of term object IDs.
 * @param string|string[] $object_type The taxonomy object type or array of the same.
 * @return void|false Void on success or if the `$object_ids` parameter is empty,
 *                    false if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $non_cached_ids = array();
    $taxonomies = get_object_taxonomies($object_type);
    foreach ($taxonomies as $taxonomy) {
        $cache_values = wp_cache_get_multiple((array) $object_ids, "{$taxonomy}_relationships");
        foreach ($cache_values as $id => $value) {
            if (false === $value) {
                $non_cached_ids[] = $id;
            }
        }
    }
    if (empty($non_cached_ids)) {
        return false;
    }
    $non_cached_ids = array_unique($non_cached_ids);
    $terms = wp_get_object_terms($non_cached_ids, $taxonomies, array('fields' => 'all_with_object_id', 'orderby' => 'name', 'update_term_meta_cache' => false));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term->term_id;
    }
    foreach ($non_cached_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    $cache_values = array();
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            $cache_values[$taxonomy][$id] = $terms;
        }
    }
    foreach ($cache_values as $taxonomy => $data) {
        wp_cache_add_multiple($data, "{$taxonomy}_relationships");
    }
}

WordPress Version: 5.7

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|int[]    $object_ids  Comma-separated list or array of term object IDs.
 * @param string|string[] $object_type The taxonomy object type or array of the same.
 * @return void|false Void on success or if the `$object_ids` parameter is empty,
 *                    false if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $non_cached_ids = array();
    $taxonomies = get_object_taxonomies($object_type);
    foreach ($taxonomies as $taxonomy) {
        $cache_values = wp_cache_get_multiple((array) $object_ids, "{$taxonomy}_relationships");
        foreach ($cache_values as $id => $value) {
            if (false === $value) {
                $non_cached_ids[] = $id;
            }
        }
    }
    if (empty($non_cached_ids)) {
        return false;
    }
    $non_cached_ids = array_unique($non_cached_ids);
    $terms = wp_get_object_terms($non_cached_ids, $taxonomies, array('fields' => 'all_with_object_id', 'orderby' => 'name', 'update_term_meta_cache' => false));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term->term_id;
    }
    foreach ($non_cached_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 5.5

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|int[]    $object_ids  Comma-separated list or array of term object IDs.
 * @param string|string[] $object_type The taxonomy object type or array of the same.
 * @return void|false False if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $non_cached_ids = array();
    $taxonomies = get_object_taxonomies($object_type);
    foreach ($taxonomies as $taxonomy) {
        $cache_values = wp_cache_get_multiple((array) $object_ids, "{$taxonomy}_relationships");
        foreach ($cache_values as $id => $value) {
            if (false === $value) {
                $non_cached_ids[] = $id;
            }
        }
    }
    if (empty($non_cached_ids)) {
        return false;
    }
    $non_cached_ids = array_unique($non_cached_ids);
    $terms = wp_get_object_terms($non_cached_ids, $taxonomies, array('fields' => 'all_with_object_id', 'orderby' => 'name', 'update_term_meta_cache' => false));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term->term_id;
    }
    foreach ($non_cached_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 5.3

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|int[]    $object_ids  Comma-separated list or array of term object IDs.
 * @param string|string[] $object_type The taxonomy object type or array of the same.
 * @return void|false False if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id', 'orderby' => 'name', 'update_term_meta_cache' => false));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term->term_id;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 4.6

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|array $object_ids  Comma-separated list or array of term object IDs.
 * @param array|string $object_type The taxonomy object type.
 * @return void|false False if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id', 'orderby' => 'name', 'update_term_meta_cache' => false));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term->term_id;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 4.1

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|array $object_ids  Comma-separated list or array of term object IDs.
 * @param array|string $object_type The taxonomy object type.
 * @return void|false False if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id', 'orderby' => 'name', 'update_term_meta_cache' => false));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 4.4

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|array $object_ids  Comma-separated list or array of term object IDs.
 * @param array|string $object_type The taxonomy object type.
 * @return void|false False if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id', 'orderby' => 'none', 'update_term_meta_cache' => false));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 4.3

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|array $object_ids  Comma-separated list or array of term object IDs.
 * @param array|string $object_type The taxonomy object type.
 * @return void|false False if all of the terms in `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id'));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 4.2

/**
 * Updates the cache for the given term object ID(s).
 *
 * Note: Due to performance concerns, great care should be taken to only update
 * term caches when necessary. Processing time can increase exponentially depending
 * on both the number of passed term IDs and the number of taxonomies those terms
 * belong to.
 *
 * Caches will only be updated for terms not already cached.
 *
 * @since 2.3.0
 *
 * @param string|array $object_ids  Comma-separated list or array of term object IDs..
 * @param array|string $object_type The taxonomy object type.
 * @return null|false Null if `$object_ids` is empty, false if all of the terms in
 *                    `$object_ids` are already cached.
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id'));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][] = $term;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 4.1

/**
 * Updates the cache for Term ID(s).
 *
 * Will only update the cache for terms not already cached.
 *
 * The $object_ids expects that the ids be separated by commas, if it is a
 * string.
 *
 * It should be noted that update_object_term_cache() is very time extensive. It
 * is advised that the function is not called very often or at least not for a
 * lot of terms that exist in a lot of taxonomies. The amount of time increases
 * for each term and it also increases for each taxonomy the term belongs to.
 *
 * @since 2.3.0
 *
 * @param string|array $object_ids Single or list of term object ID(s)
 * @param array|string $object_type The taxonomy object type
 * @return null|false Null value is given with empty $object_ids. False if
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id'));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 3.9

/**
 * Updates the cache for Term ID(s).
 *
 * Will only update the cache for terms not already cached.
 *
 * The $object_ids expects that the ids be separated by commas, if it is a
 * string.
 *
 * It should be noted that update_object_term_cache() is very time extensive. It
 * is advised that the function is not called very often or at least not for a
 * lot of terms that exist in a lot of taxonomies. The amount of time increases
 * for each term and it also increases for each taxonomy the term belongs to.
 *
 * @since 2.3.0
 * @uses wp_get_object_terms() Used to get terms from the database to update
 *
 * @param string|array $object_ids Single or list of term object ID(s)
 * @param array|string $object_type The taxonomy object type
 * @return null|bool Null value is given with empty $object_ids. False if
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id'));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}

WordPress Version: 3.7

/**
 * Updates the cache for Term ID(s).
 *
 * Will only update the cache for terms not already cached.
 *
 * The $object_ids expects that the ids be separated by commas, if it is a
 * string.
 *
 * It should be noted that update_object_term_cache() is very time extensive. It
 * is advised that the function is not called very often or at least not for a
 * lot of terms that exist in a lot of taxonomies. The amount of time increases
 * for each term and it also increases for each taxonomy the term belongs to.
 *
 * @package WordPress
 * @subpackage Taxonomy
 * @since 2.3.0
 * @uses wp_get_object_terms() Used to get terms from the database to update
 *
 * @param string|array $object_ids Single or list of term object ID(s)
 * @param array|string $object_type The taxonomy object type
 * @return null|bool Null value is given with empty $object_ids. False if
 */
function update_object_term_cache($object_ids, $object_type)
{
    if (empty($object_ids)) {
        return;
    }
    if (!is_array($object_ids)) {
        $object_ids = explode(',', $object_ids);
    }
    $object_ids = array_map('intval', $object_ids);
    $taxonomies = get_object_taxonomies($object_type);
    $ids = array();
    foreach ((array) $object_ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (false === wp_cache_get($id, "{$taxonomy}_relationships")) {
                $ids[] = $id;
                break;
            }
        }
    }
    if (empty($ids)) {
        return false;
    }
    $terms = wp_get_object_terms($ids, $taxonomies, array('fields' => 'all_with_object_id'));
    $object_terms = array();
    foreach ((array) $terms as $term) {
        $object_terms[$term->object_id][$term->taxonomy][$term->term_id] = $term;
    }
    foreach ($ids as $id) {
        foreach ($taxonomies as $taxonomy) {
            if (!isset($object_terms[$id][$taxonomy])) {
                if (!isset($object_terms[$id])) {
                    $object_terms[$id] = array();
                }
                $object_terms[$id][$taxonomy] = array();
            }
        }
    }
    foreach ($object_terms as $id => $value) {
        foreach ($value as $taxonomy => $terms) {
            wp_cache_add($id, $terms, "{$taxonomy}_relationships");
        }
    }
}