[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
Sun Sep 11 12:27:21 UTC 2016


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

 * keywords:  needs-testing needs-patch => needs-testing has-patch has-unit-
     tests


Comment:

 >If you instead change `get_translations_for_domain()` as you suggested to
 return `$noop_translations` upon first fail, wouldn't it still go through
 the `_load_textdomain_just_in_time()` process each time anyway (within the
 if statement on line 875)?

 Not if the function was rewritten a bit. I should've explained it a bit
 further I guess.

 > Couldn't you just unload the textdomain where I explicitly added the
 domain to the `$l10n_unloaded` array in `_load_textdomain_just_in_time()`?
 That would also require a change to `unload_textdomain()` to allow the
 domain to be added to the `$l10n_unloaded` array regardless of whether
 `$plugin_override` is true or if the domain exists within the `$l10n`
 array (which in this case would not).

 Thinking more about it, it really makes more sense to go this route. Also,
 a `is_textdomain_unloaded()` function is indeed handy.

 In [attachment:37997.diff] I turned your adjustments to the `l10n.php`
 file into a proper patch. Makes it easier to discuss any changes.

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


More information about the wp-trac mailing list