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.
Built from https://develop.svn.wordpress.org/branches/6.5@57838


git-svn-id: http://core.svn.wordpress.org/branches/6.5@57339 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2024-03-15 11:20:06 +00:00
parent 4af7fa8ec0
commit 2d39c954a2
3 changed files with 8 additions and 7 deletions

View File

@ -183,8 +183,8 @@ class WP_Textdomain_Registry {
return $files;
}
$cache_key = 'cached_mo_files_' . md5( $path );
$files = wp_cache_get( $cache_key, 'translations' );
$cache_key = md5( $path );
$files = wp_cache_get( $cache_key, 'translation_files' );
if ( false === $files ) {
$files = glob( $path . '*.mo' );
@ -197,7 +197,7 @@ class WP_Textdomain_Registry {
$files = array_merge( $files, $php_files );
}
wp_cache_set( $cache_key, $files, 'translations' );
wp_cache_set( $cache_key, $files, 'translation_files', HOUR_IN_SECONDS );
}
return $files;
@ -246,13 +246,13 @@ class WP_Textdomain_Registry {
foreach ( $translation_types as $type ) {
switch ( $type ) {
case 'plugin':
wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins/' ), 'translations' );
wp_cache_delete( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' );
break;
case 'theme':
wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes/' ), 'translations' );
wp_cache_delete( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' );
break;
default:
wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/' ), 'translations' );
wp_cache_delete( md5( WP_LANG_DIR . '/' ), 'translation_files' );
break;
}
}

View File

@ -876,6 +876,7 @@ function wp_start_object_cache() {
'site-queries',
'site-transient',
'theme_files',
'translation_files',
'rss',
'users',
'user-queries',

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.5-RC2-57837';
$wp_version = '6.5-RC2-57838';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.