[wp-trac] [WordPress Trac] #44221: `get_terms()` with `all_with_object_id` returns cached `stdClass` objects

WordPress Trac noreply at wordpress.org
Fri May 25 00:36:25 UTC 2018


#44221: `get_terms()` with `all_with_object_id` returns cached `stdClass` objects
--------------------------+-----------------------------
 Reporter:  dlh           |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  4.7
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 Two identical calls to `get_terms()` with `'fields' =>
 'all_with_object_id'` will return an array of `WP_Term` objects for the
 first call but an array of `stdClass` objects for the second call if the
 objects are retrieved from the cache.

 It looks to me like this was caused by a missed case of updating

 `if ( 'all' === $_fields )`

 to

 `if ( 'all' === $_fields || 'all_with_object_id' === $_fields )`

 in [38667]. It seems unintentional, but I might be missing something.

 The attached patch includes a test demonstrating the issue and a potential
 patch.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44221>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list