[wp-trac] [WordPress Trac] #41679: get_the_terms does not return expected results

WordPress Trac noreply at wordpress.org
Mon Aug 21 15:44:05 UTC 2017


#41679: get_the_terms does not return expected results
-------------------------------+------------------------------
 Reporter:  rslotb             |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Taxonomy           |     Version:  4.8.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------
Changes (by boonebgorges):

 * keywords:   => reporter-feedback


Comment:

 Hi @rslotb - Thanks for your ticket, and welcome to WordPress Trac!

 Can you say more about your debugging? If `get_the_terms()` returns a
 different value from `wp_get_object_terms()`, it suggests that the cache
 is corrupt. See https://core.trac.wordpress.org/browser/tags/4.8.1/src/wp-
 includes/category-template.php?marks=1200#L1186. If `get_the_terms()`
 finds an empty cache, it should call `wp_get_object_terms()` (see line
 1202), in which case it would be impossible for the two values to differ.

 It's also unclear to me how converting `$terms` to `WP_Term` objects would
 result in a null result (I assume "...returns no results" means it's an
 empty array?). If `$terms` is an array of database query results, then the
 `WP_Term` objects should always be populated. What is the value of
 `$terms` before and after line 814?
 https://core.trac.wordpress.org/browser/tags/4.8.1/src/wp-includes/class-
 wp-term-query.php?marks=814#L811

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


More information about the wp-trac mailing list