[wp-trac] [WordPress Trac] #54459: Give get_option a third parameter to prevent DB queries

WordPress Trac noreply at wordpress.org
Wed Nov 17 10:22:49 UTC 2021


#54459: Give get_option a third parameter to prevent DB queries
--------------------------------+-----------------------------
 Reporter:  joostdevalk         |      Owner:  (none)
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Options, Meta APIs  |    Version:
 Severity:  normal              |   Keywords:  has-patch
  Focuses:                      |
--------------------------------+-----------------------------
 If you start looking for queries to optimize on any random WordPress site,
 you'll find queries like this:

 {{{
 SELECT option_value FROM bphtc_options WHERE option_name = 'WPLANG' LIMIT
 1
 }}}

 where this happens for WPLANG, but also for lots of other options. This
 only happens when the option doesn't exist, because core already does this
 query before all of them:

 {{{
 SELECT option_name, option_value FROM bphtc_options WHERE autoload = 'yes'
 }}}

 Because it does that, we can prevent queries like the former to happen
 entirely if we know that it *should* be auto loaded. To be able to do that
 we should add a third parameter to `get_option()` that allows us to say
 "don't fallback to a database query if this option wasn't auto loaded".

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54459>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list