wp_get_object_terms should return arrays of integers for IDs and tt_IDs
|Reported by:||simonwheatley||Owned by:|
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 );
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.
Change History (23)
- Keywords 3.3-early added
- Milestone changed from Awaiting Review to Future Release
- Cc kurtpayne added
- Milestone changed from Future Release to 3.6
- Keywords 3.7-early added; 3.3-early punt removed
- Milestone changed from 3.6 to Future Release