Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#27557 closed enhancement (fixed)

Make operator case insensitive in tax queries

Reported by: clifgriffin Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.1
Component: Query Keywords: needs-refresh has-patch
Focuses: Cc:


In WP_Tax_Query::get_sql() the operator is assumed / required to be uppercase.

This conforms to preferred SQL syntax, but there isn't a good reason I can think of to enforce this here.

The simplest fix is is to force $operator to uppercase, allowing for a variety of input. I'm attaching a patch to that effect.

Attachments (2)

27557.patch (547 bytes) - added by clifgriffin 6 years ago.
whitespace.png (14.3 KB) - added by wonderboymusic 6 years ago.

Download all attachments as: .zip

Change History (9)

6 years ago

#1 @johnbillion
6 years ago

  • Version changed from trunk to 3.1

#2 @wonderboymusic
6 years ago

  • Keywords needs-refresh has-patch added
  • Milestone changed from Awaiting Review to 4.0

#3 @wonderboymusic
6 years ago

  • Milestone 4.0 deleted
  • Status changed from new to closed

Needs whitespace rehabilitation

#4 follow-up: @wonderboymusic
6 years ago

  • Milestone set to 4.0
  • Status changed from closed to reopened

#5 in reply to: ↑ 4 @clifgriffin
6 years ago

Replying to wonderboymusic:

Not sure what you're referring to. Could you clarify? Happy to make any necessary changes.


#6 @wonderboymusic
6 years ago

I have attached a screenshot - needs to be tabs instead of spaces, and needs whitespace like so:

$operator = strtoupper( $operator );

#7 @wonderboymusic
6 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from reopened to closed

In 28618:

When queries are passed to WP_Tax_Query, the value for operator is assumed to be uppercase. This is an unnecessary constraint. In ->get_sql(), cast it using $operator = strtoupper( $query['operator'] ).

Props clifgriffin.
Fixes #27557.

Note: See TracTickets for help on using tickets.