Opened 11 years ago
Closed 11 years ago
#26339 closed defect (bug) (fixed)
Pass by reference in wp_get_object_terms()
Reported by: | stephenharris | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 3.8 | Priority: | normal |
Severity: | normal | Version: | 3.8 |
Component: | Taxonomy | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Hi, I've noticed a bug in the current beta version: 3.8-beta-1-26375. I've tracked it down to this patch: http://core.trac.wordpress.org/attachment/ticket/17646/17646.3.diff (#17646).
Each term in the foreach
of the $terms
array is passed by reference when sanitising the term. However, this is not unset after the foreach
loop.
As such the seemly innocuous code changes the last term from an object to an integer:
add_filter( 'wp_get_object_terms', 'my_get_object_terms_callback' ); function my_get_object_terms_callback( $terms ){ // var_dump reveals an array of objects $term_ids = wp_list_pluck( $terms, 'term_id' ); // last term is now an integer return $terms; }
( I'm aware wp_get_object_terms
filter isn't necessarily filtering term objects, but this highlights the bug).
Attachments (2)
Change History (7)
Note: See
TracTickets for help on using
tickets.
Unset references after foreach loop