Make WordPress Core


Ignore:
Timestamp:
10/24/2022 06:35:30 PM (4 years ago)
Author:
ocean90
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.
Merges [54669] to the 6.1 branch.
See #39210.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/l10n.php

    r54351 r54682  
    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.