Make WordPress Core

Opened 3 years ago

#39826 new enhancement

LIMIT clause not required in get_options function as there's already a UNIQUE KEY on option_name

Reported by: arjenlentz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.2
Component: General Keywords:
Focuses: Cc:
PR Number:


The Core get_options (wp-includes/option.php) uses LIMIT 1 to retrieve only a single row for an option.
However, the option_name field already has a UNIQUE KEY in the table schema, so it's impossible for the db to contain or return more than one row for any option_name.

Barring history I'm unaware of (if there used to not be a UNIQUE KEY on this field in the past), it's safe to remove the LIMIT 1 clauses from these queries (there are a few instances in the function.

While LIMIT clauses can sometimes be harmful to performance, in this particular scenario that's not the case. However, it's just superfluous.

Change History (0)

Note: See TracTickets for help on using tickets.