Opened 12 years ago
Closed 12 years ago
#20711 closed defect (bug) (fixed)
Some posts queries with menu_order are ambiguous
Reported by: | markjaquith | Owned by: | ryan |
---|---|---|---|
Milestone: | 3.4 | Priority: | high |
Severity: | major | Version: | |
Component: | General | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
Starting in 3.4, I started getting errors like this:
WordPress database error Column 'menu_order' in order clause is ambiguous for query SELECT txfx_wp_posts.ID FROM txfx_wp_posts LEFT JOIN txfx_wp_posts AS p2 ON (txfx_wp_posts.post_parent = p2.ID) WHERE 1=1 AND txfx_wp_posts.ID IN (12163,12164,12165,12166,12167,12168,12169,12170,12171,12172) AND (txfx_wp_posts.post_mime_type LIKE 'image/%') AND txfx_wp_posts.post_type = 'attachment' AND ((txfx_wp_posts.post_status = 'inherit') OR (txfx_wp_posts.post_status = 'inherit' AND (p2.post_status = 'inherit'))) ORDER BY menu_order,txfx_wp_posts.ID ASC LIMIT 0, 10
It relates to the "[gallery]" shortcode. The code issue predates 3.4, but I think that the query itself changed to be a self-join, which introduces the ambiguity.
This is solved by prefixing menu_order with the table name, like we do for the other ones. See patch.
Attachments (1)
Change History (4)
Note: See
TracTickets for help on using
tickets.
Looks good.