Changeset 27101 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 02/06/2014 01:40:05 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r27057 r27101 1877 1877 $wpdb->update( $wpdb->term_taxonomy, compact( 'parent' ), array( 'parent' => $term_obj->term_id) + compact( 'taxonomy' ) ); 1878 1878 do_action( 'edited_term_taxonomies', $edit_tt_ids ); 1879 set_taxonomy_last_changed( $taxonomy ); 1879 1880 } 1880 1881 … … 1911 1912 1912 1913 clean_term_cache($term, $taxonomy); 1914 set_taxonomy_last_changed( $taxonomy ); 1913 1915 1914 1916 do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_term ); … … 2163 2165 $wpdb->update($wpdb->terms, compact('term_group'), array('term_id' => $alias->term_id) ); 2164 2166 do_action( 'edited_terms', $alias->term_id, $taxonomy ); 2167 set_taxonomy_last_changed( $taxonomy ); 2165 2168 } 2166 2169 } … … 2224 2227 2225 2228 clean_term_cache($term_id, $taxonomy); 2229 set_taxonomy_last_changed( $taxonomy ); 2226 2230 2227 2231 do_action("created_term", $term_id, $tt_id, $taxonomy); … … 2330 2334 2331 2335 wp_cache_delete( $object_id, $taxonomy . '_relationships' ); 2336 set_taxonomy_last_changed( $taxonomy ); 2332 2337 2333 2338 do_action('set_object_terms', $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); … … 2408 2413 do_action( 'deleted_term_relationships', $object_id, $tt_ids ); 2409 2414 wp_update_term_count( $tt_ids, $taxonomy ); 2415 set_taxonomy_last_changed( $taxonomy ); 2410 2416 2411 2417 return (bool) $deleted; … … 2566 2572 $wpdb->update( $wpdb->terms, compact('term_group'), array( 'term_id' => $alias->term_id ) ); 2567 2573 do_action( 'edited_terms', $alias->term_id, $taxonomy ); 2574 set_taxonomy_last_changed( $taxonomy ); 2568 2575 } 2569 2576 } … … 2601 2608 2602 2609 clean_term_cache($term_id, $taxonomy); 2610 set_taxonomy_last_changed( $taxonomy ); 2603 2611 2604 2612 do_action("edited_term", $term_id, $tt_id, $taxonomy); … … 2739 2747 $taxonomies = get_object_taxonomies( $object_type ); 2740 2748 2741 foreach ( $object_ids as $id ) 2742 foreach ( $taxonomies as $taxonomy ) 2749 foreach ( $object_ids as $id ) { 2750 foreach ( $taxonomies as $taxonomy ) { 2743 2751 wp_cache_delete($id, "{$taxonomy}_relationships"); 2752 set_taxonomy_last_changed( $taxonomy ); 2753 } 2754 } 2744 2755 2745 2756 do_action('clean_object_term_cache', $object_ids, $object_type); … … 2801 2812 2802 2813 do_action('clean_term_cache', $ids, $taxonomy); 2814 set_taxonomy_last_changed( $taxonomy ); 2803 2815 } 2804 2816 … … 2820 2832 */ 2821 2833 function get_object_term_cache($id, $taxonomy) { 2834 if ( ! post_taxonomy_is_fresh( $id, $taxonomy ) ) { 2835 return false; 2836 } 2822 2837 $cache = wp_cache_get($id, "{$taxonomy}_relationships"); 2823 2838 return $cache; … … 3118 3133 do_action( 'edited_term_taxonomy', $term, $taxonomy ); 3119 3134 } 3135 set_taxonomy_last_changed( $taxonomy->name ); 3120 3136 } 3121 3137 … … 3143 3159 do_action( 'edited_term_taxonomy', $term, $taxonomy ); 3144 3160 } 3161 set_taxonomy_last_changed( $taxonomy->name ); 3145 3162 } 3146 3163 … … 3470 3487 return $parent; 3471 3488 } 3489 3490 /** 3491 * Retrieve the 'last_changed' value for the passed taxonomy. Retrieves 3492 * from cache, if present 3493 * 3494 * @since 3.9.0 3495 * 3496 * @param string $taxonomy 3497 * @return int 3498 */ 3499 function get_taxonomy_last_changed( $taxonomy ) { 3500 $last_changed = wp_cache_get( 'last_changed', $taxonomy ); 3501 if ( ! $last_changed ) { 3502 $last_changed = microtime(); 3503 wp_cache_set( 'last_changed', $last_changed, $taxonomy ); 3504 } 3505 return $last_changed; 3506 } 3507 3508 /** 3509 * Reset 'last_changed' for the passed taxonomy 3510 * 3511 * @since 3.9.0 3512 * 3513 * @param string $taxonomy 3514 * @return int 3515 */ 3516 function set_taxonomy_last_changed( $taxonomy ) { 3517 wp_cache_delete( 'last_changed', $taxonomy ); 3518 return get_taxonomy_last_changed( $taxonomy ); 3519 } 3520 3521 /** 3522 * Determine if a post's cache for the passed taxonomy 3523 * is in sync. 3524 * @since 3.9.0 3525 * 3526 * @param int $id 3527 * @param string $taxonomy 3528 * @return boolean 3529 */ 3530 function post_taxonomy_is_fresh( $id, $taxonomy ) { 3531 $last_changed = get_taxonomy_last_changed( $taxonomy ); 3532 $post_last_changed = wp_cache_get( $id, $taxonomy . '_last_changed' ); 3533 if ( ! $post_last_changed || $last_changed !== $post_last_changed ) { 3534 wp_cache_set( $id, $last_changed, $taxonomy . '_last_changed' ); 3535 return false; 3536 } 3537 return true; 3538 }
Note: See TracChangeset
for help on using the changeset viewer.