Make WordPress Core


Ignore:
Timestamp:
05/29/2023 08:34:43 AM (2 years ago)
Author:
swissspidy
Message:

I18N: Improve _load_textdomain_just_in_time() logic when there are no translation files.

Fixes a performance issue where the JIT logic is invoked for every translation call if the there are no translations in the current locale. With this change, the information is cached by adding Noop_Translations instances to the global $l10n array. This way, get_translations_for_domain() returns earlier, thus avoiding subsequent _load_textdomain_just_in_time() calls.

Props swissspidy, johnbillion, ocean90.
Fixes #58321.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-textdomain-registry.php

    r55349 r55865  
    9898    public function has( $domain ) {
    9999        return (
    100             ! empty( $this->current[ $domain ] ) ||
     100            isset( $this->current[ $domain ] ) ||
    101101            empty( $this->all[ $domain ] ) ||
    102102            in_array( $domain, $this->domains_with_translations, true )
Note: See TracChangeset for help on using the changeset viewer.