[wp-trac] [WordPress Trac] #37997: Increase in function calls to get_locale() because of _load_textdomain_just_in_time()

WordPress Trac noreply at wordpress.org
Mon Nov 21 16:06:39 UTC 2016


#37997: Increase in function calls to get_locale() because of
_load_textdomain_just_in_time()
-------------------------------------------------+-------------------------
 Reporter:  sharkomatic                          |       Owner:  ocean90
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  4.7
Component:  I18N                                 |     Version:  4.6
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  needs-testing has-patch has-unit-    |     Focuses:
  tests                                          |  performance
-------------------------------------------------+-------------------------
Changes (by ocean90):

 * status:  reviewing => closed
 * resolution:   => fixed


Comment:

 In [changeset:"39330"]:
 {{{
 #!CommitTicketReference repository="" revision="39330"
 I18N: Add an additional caching layer for
 `_load_textdomain_just_in_time()`.

 Previously, if no translation files exist for a text domain,
 `_load_textdomain_just_in_time()` went through the entire process each
 time it was called. This results in an increased call to `get_locale()`
 and its `locale` filter.
 This change splits the logic into `_get_path_to_translation()` and
 `_get_path_to_translation_from_lang_dir()`. The former, which is used by
 `_load_textdomain_just_in_time()`, caches the result of the latter. It
 also removes some non-working code from
 `WP_Locale_Switcher::load_translations()`.

 Props jrf, swissspidy, sharkomatic, ocean90.
 Fixes #37997.
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37997#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list