#37904 closed defect (bug) (fixed)
PHP warning when `include` is passed for `orderby` in get_terms()
Reported by: | rabmalin | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Query | Keywords: | has-patch |
Focuses: | Cc: |
Description
Steps to reproduce:
<?php $args = array( 'include' => '2,4,3', 'orderby' => 'include', ); $terms = get_terms( $args );
Output:
Warning: array_map(): Argument #2 should be an array in /var/www/trunk.dev/public_html/wp-includes/class-wp-term-query.php on line 776
Warning: implode(): Invalid arguments passed in /var/www/trunk.dev/public_html/wp-includes/class-wp-term-query.php on line 776
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ASC' at line 1]
SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN ( 2,4,3 ) AND tt.count > 0 ORDER BY FIELD( t.term_id, ) ASC
Environment:
- WP version: 4.7-alpha-38492
Attachments (2)
Change History (9)
#6
follow-up:
↓ 7
@
8 years ago
@dd32 It's not a 4.6 regression, and not even a 4.1 regression, strictly - it was an oversight when the feature was first introduced. That said, it's minor and perfectly safe for 4.6.x inclusion, if you think it's warranted.
#7
in reply to:
↑ 6
@
8 years ago
Replying to boonebgorges:
@dd32 It's not a 4.6 regression, and not even a 4.1 regression, strictly - it was an oversight when the feature was first introduced. That said, it's minor and perfectly safe for 4.6.x inclusion, if you think it's warranted.
I misread it and thought that orderby=include
was a 4.6 thing, never mind, this doesn't need to be in a 4.6.x
Thanks for the ticket and for the patches! Introduced in [30052]; it was assumed there that
'include'
would always be an array, not a comma-separated list.