[wp-trac] [WordPress Trac] #17646: wp_get_object_terms should return arrays of integers for IDs and tt_IDs
WordPress Trac
wp-trac at lists.automattic.com
Wed Jun 1 18:00:41 UTC 2011
#17646: wp_get_object_terms should return arrays of integers for IDs and tt_IDs
---------------------------+------------------------------------
Reporter: simonwheatley | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Taxonomy | Version: 3.2
Severity: normal | Keywords: has-patch dev-feedback
---------------------------+------------------------------------
Currently when you use ```wp_get_object_terms``` to request an array of
IDs or tt_IDs, the array returned contains strings representing the IDs,
not integers. This then creates issues if you send the values back into
```wp_set_object_terms``` as it creates terms named as per those strings,
rather than associating the term_ids as expected.
Code to prove the issue:
{{{
$term_ids = wp_get_object_terms( get_the_ID(), 'category', array( 'fields'
=> 'tt_ids' ) );
var_dump( $term_ids );
}}}
Results in:
{{{
array
0 => string '1' (length=1)
1 => string '5' (length=1)
}}}
I believe that the array should have all values cast to integers before
they are returned. The attached patch does this by mapping a created
function to utilise ```(int)``` for the desired result.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17646>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list