Make WordPress Core


Ignore:
Timestamp:
03/15/2024 11:17:54 AM (2 years ago)
Author:
swissspidy
Message:

I18N: Improve translation file cache group & expiration.

Adds an explicit 1 hour expiration for the translation file cache introduced in [57287] / #58919.
This prevents stale caches when a site does not use the regular way of installing language packs, for example when an atomic filesystem is involved.
Also configures the translation_files group as a global cache group on multisite.

Reviewed by swissspidy.
Merges [57831] to the to the 6.5 branch.

Props dd32.
Fixes #60764.

Location:
branches/6.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/tests/phpunit/tests/l10n/wpTextdomainRegistry.php

    r57516 r57838  
    2020
    2121        public function tear_down() {
    22                 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/foobar/' ), 'translations' );
    23                 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins/' ), 'translations' );
    24                 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes/' ), 'translations' );
    25                 wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/' ), 'translations' );
     22                wp_cache_delete( md5( WP_LANG_DIR . '/foobar/' ), 'translation_files' );
     23                wp_cache_delete( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' );
     24                wp_cache_delete( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' );
     25                wp_cache_delete( md5( WP_LANG_DIR . '/' ), 'translation_files' );
    2626
    2727                parent::tear_down();
     
    5050                );
    5151                $this->assertNotFalse(
    52                         wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/bar/' ), 'translations' ),
     52                        wp_cache_get( md5( WP_LANG_DIR . '/bar/' ), 'translation_files' ),
    5353                        'List of files in custom path not cached'
    5454                );
     
    9090                $this->instance->get_language_files_from_path( WP_LANG_DIR . '/' );
    9191
    92                 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins/' ), 'translations' ) );
    93                 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes/' ), 'translations' ) );
    94                 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/foobar/' ), 'translations' ) );
    95                 $this->assertNotFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/' ), 'translations' ) );
     92                $this->assertNotFalse( wp_cache_get( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' ) );
     93                $this->assertNotFalse( wp_cache_get( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' ) );
     94                $this->assertNotFalse( wp_cache_get( md5( WP_LANG_DIR . '/foobar/' ), 'translation_files' ) );
     95                $this->assertNotFalse( wp_cache_get( md5( WP_LANG_DIR . '/' ), 'translation_files' ) );
    9696        }
    9797
     
    104104                remove_filter( 'pre_get_language_files_from_path', '__return_empty_array' );
    105105
    106                 $cache = wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins/' ), 'translations' );
     106                $cache = wp_cache_get( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' );
    107107
    108108                $this->assertEmpty( $result );
     
    145145                );
    146146
    147                 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins/' ), 'translations' ) );
    148                 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes/' ), 'translations' ) );
    149                 $this->assertFalse( wp_cache_get( 'cached_mo_files_' . md5( WP_LANG_DIR . '/' ), 'translations' ) );
     147                $this->assertFalse( wp_cache_get( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' ) );
     148                $this->assertFalse( wp_cache_get( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' ) );
     149                $this->assertFalse( wp_cache_get( md5( WP_LANG_DIR . '/' ), 'translation_files' ) );
    150150        }
    151151
Note: See TracChangeset for help on using the changeset viewer.