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/tests/phpunit/tests/l10n/wpLocaleSwitcher.php

    r54088 r54682  
    2828                global $wp_textdomain_registry;
    2929
    30                 $wp_textdomain_registry->reset();
     30                $wp_textdomain_registry = new WP_Textdomain_Registry();
    3131        }
    3232
     
    3737                global $wp_textdomain_registry;
    3838
    39                 $wp_textdomain_registry->reset();
     39                $wp_textdomain_registry = new WP_Textdomain_Registry();
    4040
    4141                parent::tear_down();
     
    479479                require_once DIR_TESTDATA . '/plugins/custom-internationalized-plugin/custom-internationalized-plugin.php';
    480480
     481                $actual = custom_i18n_plugin_test();
     482
     483                switch_to_locale( 'es_ES' );
     484
    481485                $registry_value = $wp_textdomain_registry->get( 'custom-internationalized-plugin', determine_locale() );
    482486
    483                 $actual = custom_i18n_plugin_test();
    484 
    485                 switch_to_locale( 'es_ES' );
    486487                switch_to_locale( 'de_DE' );
    487488
     
    518519                require_once get_stylesheet_directory() . '/functions.php';
    519520
     521                $actual = custom_i18n_theme_test();
     522
     523                switch_to_locale( 'es_ES' );
     524
    520525                $registry_value = $wp_textdomain_registry->get( 'custom-internationalized-theme', determine_locale() );
    521526
    522                 $actual = custom_i18n_theme_test();
    523 
    524                 switch_to_locale( 'es_ES' );
    525527                switch_to_locale( 'de_DE' );
    526528
Note: See TracChangeset for help on using the changeset viewer.