diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index f407621..1d93f69 100644
|
|
|
function get_terms( $taxonomies, $args = '' ) { |
| 1912 | 1912 | } |
| 1913 | 1913 | |
| 1914 | 1914 | $terms = $wpdb->get_results($query); |
| | 1915 | if ( 'all' == $_fields ) { |
| | 1916 | update_term_cache( $terms ); |
| | 1917 | } |
| 1915 | 1918 | |
| 1916 | 1919 | if ( empty($terms) ) { |
| 1917 | 1920 | wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS ); |
diff --git tests/phpunit/tests/term/cache.php tests/phpunit/tests/term/cache.php
index d424353..ebb72c6 100644
|
|
|
class Tests_Term_Cache extends WP_UnitTestCase { |
| 93 | 93 | |
| 94 | 94 | _unregister_taxonomy( $tax ); |
| 95 | 95 | } |
| | 96 | |
| | 97 | /** |
| | 98 | * @ticket 30749 |
| | 99 | */ |
| | 100 | public function test_get_terms_should_update_cache_for_located_terms() { |
| | 101 | global $wpdb; |
| | 102 | |
| | 103 | register_taxonomy( 'wptests_tax', 'post' ); |
| | 104 | |
| | 105 | $terms = $this->factory->term->create_many( 5, array( |
| | 106 | 'taxonomy' => 'wptests_tax', |
| | 107 | ) ); |
| | 108 | |
| | 109 | $term_objects = get_terms( 'wptests_tax', array( |
| | 110 | 'hide_empty' => false, |
| | 111 | ) ); |
| | 112 | |
| | 113 | $num_queries = $wpdb->num_queries; |
| | 114 | |
| | 115 | foreach ( $terms as $term_id ) { |
| | 116 | get_term( $term_id, 'wptests_tax' ); |
| | 117 | } |
| | 118 | |
| | 119 | $this->assertSame( $num_queries, $wpdb->num_queries ); |
| | 120 | |
| | 121 | _unregister_taxonomy( 'wptests_tax' ); |
| | 122 | } |
| 96 | 123 | } |