[wp-trac] [WordPress Trac] #37291: Check for WP_Error before echo in the_tags()

WordPress Trac noreply at wordpress.org
Mon Oct 10 03:41:46 UTC 2016


#37291: Check for WP_Error before echo in the_tags()
-------------------------------------+-----------------------------
 Reporter:  michalzuber              |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Future Release
Component:  Taxonomy                 |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-refresh  |     Focuses:
-------------------------------------+-----------------------------

Comment (by dd32):

 After debugging this on WordPress.com, I believe this deserves fixing much
 deeper than this as well.

 In my case, it seems the issue is that `get_the_terms()` is returning {{{
 array( WP_Term, WP_Error, WP_Term ) }}} - note the WP_Error in the middle,
 which trips up `get_term_link()` and returns that `WP_Error` there.

 The WP_Error is a `invalid_term => Empty Term` error, which appears to be
 caused by `get_object_term_cache()` calling `get_term()` on the failure of
 a `wp_cache_get()` (which should exist, as it was just set by
 `_prime_term_caches()`).

 I suspect this is caused by out-of-sync term caches.. but not sure exactly
 how that's happening.
 It does look like `get_object_term_cache()` isn't designed to handle cases
 where `_prime_term_caches()` doesn't cache all the terms.
 Based on the code in `get_object_term_cache()` I'd suggest that maybe
 `get_term()` should be called directly rather than `wp_cache_get(
 $term_id, 'terms' )` - and `WP_Error` instances from that should be
 floated up the call chain.

 cc @boonebgorges  re [37573]

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


More information about the wp-trac mailing list