Make WordPress Core

Opened 5 years ago

Closed 4 years ago

#16844 closed defect (bug) (fixed)

WP_Query::get_posts() pollutes the 'orderby' query var

Reported by: scribu Owned by:
Milestone: 3.2 Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch
Focuses: Cc:

Description (last modified by scribu)

After running through get_posts(), the 'orderby' query var no longer contains the original value, but the final SQL code.

Thus, instead of:

if ( 'some_value' == $wp_query->get( 'orderby' ) )

you have to do:

if ( isset( $wp_query->query['orderby'] ) && 'some_value' == $wp_query->query['orderby'] )

Attachments (1)

16844.diff (1.9 KB) - added by scribu 5 years ago.

Download all attachments as: .zip

Change History (5)

5 years ago

#1 @scribu
5 years ago

  • Description modified (diff)

#2 @scribu
5 years ago

  • Description modified (diff)

#3 @nacin
5 years ago

  • Milestone changed from Awaiting Review to 3.2

#4 @ryan
4 years ago

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

(In [17653]) Don't pollute orderby query var. Props scribu. fixes #16844

Note: See TracTickets for help on using tickets.