Make WordPress Core


Ignore:
Timestamp:
03/14/2024 09:04:00 AM (11 months 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.

Props dd32.
Fixes #60764.

File:
1 edited

Legend:

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

    r57639 r57831  
    184184        }
    185185
    186         $cache_key = 'cached_mo_files_' . md5( $path );
    187         $files     = wp_cache_get( $cache_key, 'translations' );
     186        $cache_key = md5( $path );
     187        $files     = wp_cache_get( $cache_key, 'translation_files' );
    188188
    189189        if ( false === $files ) {
     
    198198            }
    199199
    200             wp_cache_set( $cache_key, $files, 'translations' );
     200            wp_cache_set( $cache_key, $files, 'translation_files', HOUR_IN_SECONDS );
    201201        }
    202202
     
    247247            switch ( $type ) {
    248248                case 'plugin':
    249                     wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins/' ), 'translations' );
     249                    wp_cache_delete( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' );
    250250                    break;
    251251                case 'theme':
    252                     wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes/' ), 'translations' );
     252                    wp_cache_delete( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' );
    253253                    break;
    254254                default:
    255                     wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/' ), 'translations' );
     255                    wp_cache_delete( md5( WP_LANG_DIR . '/' ), 'translation_files' );
    256256                    break;
    257257            }
Note: See TracChangeset for help on using the changeset viewer.