diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index ab34f2e..c19e0dd 100644
|
|
function wp_validate_boolean( $var ) { |
4629 | 4629 | |
4630 | 4630 | return (bool) $var; |
4631 | 4631 | } |
4632 | | |
4633 | | /** |
4634 | | * Helper function to retrieve an incrementer identified by $group |
4635 | | * |
4636 | | * @since 4.1.0 |
4637 | | * |
4638 | | * @param string $group The cache group for the incrementer. |
4639 | | * @param bool $force Whether or not to generate a new incrementor. |
4640 | | * @return int The timestamp representing 'last_changed'. |
4641 | | */ |
4642 | | function wp_get_last_changed( $group, $force = false ) { |
4643 | | $last_changed = wp_cache_get( 'last_changed', $group ); |
4644 | | if ( ! $last_changed || true === $force ) { |
4645 | | $last_changed = microtime(); |
4646 | | wp_cache_set( 'last_changed', $last_changed, $group ); |
4647 | | } |
4648 | | return $last_changed; |
4649 | | } |
4650 | | No newline at end of file |
diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index b8261df..82280ff 100644
|
|
function get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') { |
1291 | 1291 | return $error; |
1292 | 1292 | } |
1293 | 1293 | |
1294 | | $group = $taxonomy . ':' . wp_get_last_changed( 'terms' ); |
| 1294 | $incrementor = wp_cache_get( 'last_changed', 'terms' ); |
1295 | 1295 | if ( is_object($term) && empty($term->filter) ) { |
1296 | | wp_cache_add( $term->term_id, $term, $taxonomy ); |
1297 | | wp_cache_add( "slug:{$term->slug}", $term->term_id, $group ); |
1298 | | wp_cache_add( "name:" . md5( $term->name ), $term->term_id, $group ); |
| 1296 | wp_cache_add( $term->term_id, $term, $taxonomy . ':terms:' . $incrementor ); |
| 1297 | wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); |
| 1298 | wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); |
1299 | 1299 | $_term = $term; |
1300 | 1300 | } else { |
1301 | 1301 | if ( is_object($term) ) |
… |
… |
function get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') { |
1306 | 1306 | $_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) ); |
1307 | 1307 | if ( ! $_term ) |
1308 | 1308 | return null; |
1309 | | wp_cache_add( $term, $_term, $taxonomy ); |
1310 | | wp_cache_add( "slug:{$_term->slug}", $term, $group ); |
1311 | | wp_cache_add( "name:" . md5( $_term->name ), $term, $group ); |
| 1309 | wp_cache_add( $term, $_term, $taxonomy . ':terms:' . $incrementor ); |
| 1310 | wp_cache_add( $_term->slug, $term, $taxonomy . ':slugs:' . $incrementor ); |
| 1311 | wp_cache_add( $_term->name, $term, $taxonomy . ':names:' . $incrementor ); |
1312 | 1312 | } |
1313 | 1313 | } |
1314 | 1314 | |
… |
… |
function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw |
1381 | 1381 | return false; |
1382 | 1382 | |
1383 | 1383 | $cache = false; |
1384 | | $group = $taxonomy . ':' . wp_get_last_changed( 'terms' ); |
| 1384 | $incrementor = wp_cache_get( 'last_changed', 'terms' ); |
1385 | 1385 | if ( 'slug' == $field ) { |
1386 | 1386 | $field = 't.slug'; |
1387 | 1387 | $value = sanitize_title($value); |
1388 | 1388 | if ( empty($value) ) |
1389 | 1389 | return false; |
1390 | 1390 | |
1391 | | $term_id = wp_cache_get( "slug:{$value}", $group ); |
| 1391 | $term_id = wp_cache_get( $value, $taxonomy . ':slugs:' . $incrementor ); |
1392 | 1392 | if ( $term_id ) { |
1393 | 1393 | $value = $term_id; |
1394 | 1394 | $cache = true; |
… |
… |
function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw |
1397 | 1397 | // Assume already escaped |
1398 | 1398 | $value = wp_unslash($value); |
1399 | 1399 | $field = 't.name'; |
1400 | | $term_id = wp_cache_get( "name:" . md5( $value ), $group ); |
| 1400 | $term_id = wp_cache_get( $value, $taxonomy . ':names:' . $incrementor ); |
1401 | 1401 | if ( $term_id ) { |
1402 | 1402 | $value = $term_id; |
1403 | 1403 | $cache = true; |
… |
… |
function get_term_by($field, $value, $taxonomy, $output = OBJECT, $filter = 'raw |
1429 | 1429 | |
1430 | 1430 | $term = sanitize_term($term, $taxonomy, $filter); |
1431 | 1431 | |
1432 | | wp_cache_add( $term->term_id, $term, $taxonomy ); |
1433 | | wp_cache_add( "slug:{$term->slug}", $term->term_id, $group ); |
1434 | | wp_cache_add( "name:" . md5( $term->name ), $term->term_id, $group ); |
| 1432 | wp_cache_add( $term->term_id, $term, $taxonomy . ':terms:' . $incrementor ); |
| 1433 | wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); |
| 1434 | wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); |
1435 | 1435 | |
1436 | 1436 | if ( $output == OBJECT ) { |
1437 | 1437 | return $term; |
… |
… |
function clean_term_cache($ids, $taxonomy = '', $clean_taxonomy = true) { |
3662 | 3662 | do_action( 'clean_term_cache', $ids, $taxonomy ); |
3663 | 3663 | } |
3664 | 3664 | |
3665 | | wp_get_last_changed( 'terms', true ); |
| 3665 | wp_cache_set( 'last_changed', microtime(), 'terms' ); |
3666 | 3666 | } |
3667 | 3667 | |
3668 | 3668 | /** |
… |
… |
function update_term_cache($terms, $taxonomy = '') { |
3768 | 3768 | if ( empty($term_taxonomy) ) |
3769 | 3769 | $term_taxonomy = $term->taxonomy; |
3770 | 3770 | |
3771 | | wp_cache_add( $term->term_id, $term, $term_taxonomy ); |
3772 | | $group = $term_taxonomy . ':' . wp_get_last_changed( 'terms', true ); |
3773 | | wp_cache_add( "slug:{$term->slug}", $term->term_id, $group ); |
3774 | | wp_cache_add( "name:" . md5( $term->name ), $term->term_id, $group ); |
| 3771 | $incrementor = wp_cache_set( 'last_changed', microtime(), 'terms' ); |
| 3772 | |
| 3773 | wp_cache_add( $term->term_id, $term, $term_taxonomy . ':terms:' . $incrementor ); |
| 3774 | wp_cache_add( $term->slug, $term->term_id, $taxonomy . ':slugs:' . $incrementor ); |
| 3775 | wp_cache_add( $term->name, $term->term_id, $taxonomy . ':names:' . $incrementor ); |
3775 | 3776 | } |
3776 | 3777 | } |
3777 | 3778 | |