[wp-trac] [WordPress Trac] #50980: Extra query to get WPLANG option on each page-load when the option doesn't exist in the db

WordPress Trac noreply at wordpress.org
Thu Aug 13 12:00:16 UTC 2020


#50980: Extra query to get WPLANG option on each page-load when the option doesn't
exist in the db
--------------------------+-----------------------------
 Reporter:  aristath      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  I18N          |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 On each page-load we call `determine_locale()` which in turn tries to get
 the `WPLANG` option using `get_option`.
 When the site language is `en_US` and has never been changed, the `WPLANG`
 option doesn't exist in the options table in the database.
 As a result, `get_option` doesn’t find it autoloaded and then triggers a
 query.

 If the language is changed to something else and then back to `en_US`, the
 option is saved as an empty string and gets autoloaded.

 Proposed solution:
 The simplest solution that comes to mind (which also wouldn't interfere
 with the way multilingual plugins work) would be to check if the row
 exists in the table, and if not just create it and save as empty string.
 It can then get picked-up by the object-caches and spare us the extra
 query.

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


More information about the wp-trac mailing list