[wp-trac] [WordPress Trac] #20711: Some posts queries with menu_order are ambiguous
WordPress Trac
wp-trac at lists.automattic.com
Sun May 20 00:08:55 UTC 2012
#20711: Some posts queries with menu_order are ambiguous
--------------------------+-----------------------
Reporter: markjaquith | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: 3.4
Component: General | Version:
Severity: major | Keywords: has-patch
--------------------------+-----------------------
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20711>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list