Make WordPress Core


Ignore:
Timestamp:
10/24/2022 10:01:01 AM (18 months ago)
Author:
swissspidy
Message:

I18N: Change how WP_Textdomain_Registry stores the default languages path.

WP_Textdomain_Registry was introduced in [53874] to store text domains and their language directory paths, addressing issues with just-in-time loading of textdomains when using locale switching and when usingload_*_textdomain() functions.

Said change has inadvertently caused a performance regression exactly when usingload_*_textdomain(), which still often is the case, where the cached information was not further used or even overridden.

This change addresses that issue by storing the default languages paths in a separate way, while at the same time making WP_Textdomain_Registry easier to maintain and adding new tests to catch future regressions.

Props flixos90, spacedmonkey, ocean90, SergeyBiryukov, costdev.
Fixes #39210.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/l10n.php

    r54351 r54669  
    935935    }
    936936
    937     $wp_textdomain_registry->set( $domain, $locale, $path );
     937    $wp_textdomain_registry->set_custom_path( $domain, $path );
    938938
    939939    return load_textdomain( $domain, $path . '/' . $mofile, $locale );
     
    969969    $path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
    970970
    971     $wp_textdomain_registry->set( $domain, $locale, $path );
     971    $wp_textdomain_registry->set_custom_path( $domain, $path );
    972972
    973973    return load_textdomain( $domain, $path . '/' . $mofile, $locale );
     
    10171017    }
    10181018
    1019     $wp_textdomain_registry->set( $domain, $locale, $path );
     1019    $wp_textdomain_registry->set_custom_path( $domain, $path );
    10201020
    10211021    return load_textdomain( $domain, $path . '/' . $locale . '.mo', $locale );
     
    12661266    }
    12671267
    1268     if ( $wp_textdomain_registry->has( $domain ) && ! $wp_textdomain_registry->get_current( $domain ) ) {
     1268    if ( ! $wp_textdomain_registry->has( $domain ) ) {
    12691269        return false;
    12701270    }
Note: See TracChangeset for help on using the changeset viewer.