[wp-trac] [WordPress Trac] #55887: Calling get_terms() with exact same args (most important is exclude_tree) returns unexpected results from runtime cache (second call)

WordPress Trac noreply at wordpress.org
Wed Jun 1 12:22:31 UTC 2022


#55887: Calling get_terms() with exact same args (most important is exclude_tree)
returns unexpected results from runtime cache (second call)
--------------------------+------------------------------
 Reporter:  szaqal21      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  6.0
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by szaqal21):

 One more test case:

 {{{
 echo 'exclude_tree B (111)<br>';
 var_dump(get_terms(array('taxonomy' => 'category', 'exclude_tree' => 111,
 'hide_empty' => 0, 'fields' => 'ids')));

 echo '<br><br>child_of B (111)<br>';
 var_dump(get_terms(array('taxonomy' => 'category', 'child_of' => 111,
 'hide_empty' => 0, 'fields' => 'ids')));
 }}}

 result

 {{{
 exclude_tree B (111)
 array(5) { [0]=> int(110) [1]=> int(113) [2]=> int(1) [3]=> int(112) [4]=>
 int(115) }
 // OK

 child_of B (111)
 array(7) { [0]=> int(110) [1]=> int(113) [2]=> int(111) [3]=> int(114)
 [4]=> int(1) [5]=> int(112) [6]=> int(115) }
 // WRONG
 }}}

 Second **get_terms()** results all terms not those which are children of
 parent **term_id = 111**.

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


More information about the wp-trac mailing list