Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#20711 closed defect (bug) (fixed)

Some posts queries with menu_order are ambiguous

Reported by: markjaquith's profile markjaquith Owned by: ryan's profile 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)

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

Download all attachments as: .zip

Change History (4)

#1 @ryan
12 years ago

Looks good.

#2 @ryan
12 years ago

  • Keywords commit added

#3 @ryan
12 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.