[wp-trac] [WordPress Trac] #55837: WP_Term_Query cache problem

WordPress Trac noreply at wordpress.org
Thu May 26 08:36:10 UTC 2022


#55837: WP_Term_Query cache problem
--------------------------+------------------------------
 Reporter:  denishua      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  6.0
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by oztaser):

 * component:  General => Taxonomy


Comment:

 Hi there,

 I also noticed this issue. Here is my mu-plugin to see the difference
 between cached and non-cached data:

 {{{#!php
 <?php
 namespace NefisYemekTarifleri\TERM_CACHE_TEST;

 function init() {
         $last_changed = microtime();
         wp_cache_set( 'last_changed', $last_changed, 'terms' );

         $args = array(
                 'taxonomy' => 'category',
                 'child_of' => 2219, // some category id.
         );

         $terms = get_terms( $args );
         $terms = wp_list_pluck( $terms, 'name' );

         $terms2 = get_terms( $args );
         $terms2 =  wp_list_pluck( $terms2, 'name' );

         echo count( $terms );
         var_dump( $terms );

         echo '<hr />';

         echo count( $terms2 );
         var_dump( $terms2 );
         //die();
 }
 add_action( 'init', __NAMESPACE__ . '\\init' );
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55837#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list