Changeset 30900 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 12/16/2014 01:26:19 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/taxonomy.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r30759 r30900 1306 1306 } 1307 1307 1308 $incrementor = wp_cache_get( 'last_changed', 'terms' );1309 1308 if ( is_object($term) && empty($term->filter) ) { 1310 wp_cache_add( $term->term_id, $term, $taxonomy . ':terms:' . $incrementor ); 1311 wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); 1312 wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); 1309 wp_cache_add( $term->term_id, $term, $taxonomy ); 1313 1310 $_term = $term; 1314 1311 } else { … … 1317 1314 if ( !$term = (int) $term ) 1318 1315 return null; 1319 if ( ! $_term = wp_cache_get( $term, $taxonomy . ':terms:' . $incrementor) ) {1316 if ( ! $_term = wp_cache_get( $term, $taxonomy ) ) { 1320 1317 $_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %d LIMIT 1", $taxonomy, $term) ); 1321 1318 if ( ! $_term ) 1322 1319 return null; 1323 wp_cache_add( $term, $_term, $taxonomy . ':terms:' . $incrementor ); 1324 wp_cache_add( $_term->slug, $term, $taxonomy . ':slugs:' . $incrementor ); 1325 wp_cache_add( $_term->name, $term, $taxonomy . ':names:' . $incrementor ); 1320 wp_cache_add( $term, $_term, $taxonomy ); 1326 1321 } 1327 1322 } … … 1394 1389 return false; 1395 1390 1396 $cache = false;1397 $incrementor = wp_cache_get( 'last_changed', 'terms' );1398 1391 if ( 'slug' == $field ) { 1399 1392 $field = 't.slug'; … … 1401 1394 if ( empty($value) ) 1402 1395 return false; 1403 1404 $term_id = wp_cache_get( $value, $taxonomy . ':slugs:' . $incrementor );1405 if ( $term_id ) {1406 $value = $term_id;1407 $cache = true;1408 }1409 1396 } else if ( 'name' == $field ) { 1410 1397 // Assume already escaped 1411 1398 $value = wp_unslash($value); 1412 1399 $field = 't.name'; 1413 $term_id = wp_cache_get( $value, $taxonomy . ':names:' . $incrementor );1414 if ( $term_id ) {1415 $value = $term_id;1416 $cache = true;1417 }1418 1400 } else if ( 'term_taxonomy_id' == $field ) { 1419 1401 $value = (int) $value; 1420 1402 $field = 'tt.term_taxonomy_id'; 1421 1403 } else { 1422 $cache = true; 1423 } 1424 1425 if ( $cache ) { 1426 $term = get_term( (int) $value, $taxonomy, $output, $filter); 1427 if ( is_wp_error( $term ) ) { 1404 $term = get_term( (int) $value, $taxonomy, $output, $filter ); 1405 if ( is_wp_error( $term ) ) 1428 1406 $term = false; 1429 } 1430 } else { 1431 $term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value) ); 1432 } 1433 1434 if ( !$term ) 1407 return $term; 1408 } 1409 1410 $term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND $field = %s LIMIT 1", $taxonomy, $value ) ); 1411 if ( ! $term ) 1435 1412 return false; 1413 1414 wp_cache_add( $term->term_id, $term, $taxonomy ); 1436 1415 1437 1416 /** This filter is documented in wp-includes/taxonomy.php */ … … 1442 1421 1443 1422 $term = sanitize_term($term, $taxonomy, $filter); 1444 1445 wp_cache_add( $term->term_id, $term, $taxonomy . ':terms:' . $incrementor );1446 wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor );1447 wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor );1448 1423 1449 1424 if ( $output == OBJECT ) { … … 3650 3625 */ 3651 3626 function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { 3652 global $_wp_suspend_cache_invalidation, $wpdb; 3653 3654 if ( ! empty( $_wp_suspend_cache_invalidation ) ) { 3655 return; 3656 } 3627 global $wpdb; 3657 3628 3658 3629 if ( !is_array($ids) ) … … 3793 3764 */ 3794 3765 function update_term_cache($terms, $taxonomy = '') { 3795 global $_wp_suspend_cache_invalidation;3796 3797 if ( ! empty( $_wp_suspend_cache_invalidation ) ) {3798 return;3799 }3800 3801 3766 foreach ( (array) $terms as $term ) { 3802 3767 $term_taxonomy = $taxonomy; … … 3804 3769 $term_taxonomy = $term->taxonomy; 3805 3770 3806 $incrementor = wp_cache_set( 'last_changed', microtime(), 'terms' ); 3807 3808 wp_cache_add( $term->term_id, $term, $term_taxonomy . ':terms:' . $incrementor ); 3809 wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); 3810 wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); 3771 wp_cache_add( $term->term_id, $term, $term_taxonomy ); 3811 3772 } 3812 3773 }
Note: See TracChangeset
for help on using the changeset viewer.