Make WordPress Core

Opened 2 years ago

Closed 2 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:


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)

menu_order.diff (387 bytes) - added by markjaquith 2 years ago.

Download all attachments as: .zip

Change History (4)

markjaquith2 years ago

comment:1 ryan2 years ago

Looks good.

comment:2 ryan2 years ago

  • Keywords commit added

comment:3 ryan2 years ago

  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [20836]:

Disambiguate menu_order. Props markjaquith. fixes #20711

Note: See TracTickets for help on using tickets.