[wp-trac] [WordPress Trac] #29424: Query argument 'orderby' makes duplicated parameters possible
WordPress Trac
noreply at wordpress.org
Fri Aug 29 11:56:48 UTC 2014
#29424: Query argument 'orderby' makes duplicated parameters possible
--------------------------+------------------------------
Reporter: ChriCo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by jesin):
**Cause:** The `parse_orderby()` function prefixes **post_** to names like
**date, author, title** in the "default" case of its switch block.
The **29424.diff** patch checks if a column name exists already in the
`$orderby_array` and skips a loop if it does.
I found another bug which was also patched in this file.
{{{
$query = new WP_Query( array( 'orderby' => 'post_title post_date
post_author', 'order' => 'ASC' ) );
//Outputs: wp_posts.post_title ASC, wp_posts.post_date ASC,
wp_posts.post_author
}}}
Notice the missing `ASC` for the last column. This is caused by the use of
`implode()` to add the "order" index.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29424#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list