[wp-trac] [WordPress Trac] #34723: Warning in get_the_terms() because of non-array

WordPress Trac noreply at wordpress.org
Fri Dec 18 18:28:22 UTC 2015


#34723: Warning in get_the_terms() because of non-array
-----------------------------------+---------------------------
 Reporter:  mrppp                  |       Owner:  boonebgorges
     Type:  defect (bug)           |      Status:  reopened
 Priority:  normal                 |   Milestone:  4.4.1
Component:  Taxonomy               |     Version:  4.4
 Severity:  normal                 |  Resolution:
 Keywords:  fixed-major has-patch  |     Focuses:
-----------------------------------+---------------------------

Comment (by boonebgorges):

 What @stephenharris says in [comment:10 comment 10] looks correct to me.
 By the time we get to the `! is_wp_error( $terms )` check, `$terms` should
 be set to the return value of `wp_get_object_terms()`; this latter
 function can only return an array or a `WP_Error` object.

 @joedolson It's possible that you'd get an error like this if the
 `{$taxonomy}_relationships` cache contains a non-array value. Are you sure
 that your `array_map()` error is being caused by `$terms` being set to
 `false`? It seems more likely that it'd be caused by a plugin (or core)
 caching a scalar value (or a `WP_Error` object).

 On a potentially related note, it appears that there's a related bug in
 two other places in core:
 * https://core.trac.wordpress.org/browser/tags/4.4/src/wp-
 admin/includes/template.php?marks=311-315#L305
 * https://core.trac.wordpress.org/browser/tags/4.4/src/wp-
 admin/includes/taxonomy.php?marks=242-245#L228

 As in the case of `get_the_terms()`, it's possible that a `WP_Error`
 object could be erroneously cached here. This is not a regression for 4.4
 (and [35851] should cover any potential collateral damage when
 `get_the_terms()` attempts to access a corrupt cache), but probably ought
 to be addressed. @joedolson Is it possible that your issue stems from one
 of the above, or a similar issue in a plugin?

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


More information about the wp-trac mailing list