From ce8ed7dfa188ce1383fb106dc98c62dc5170ab3c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 14 Mar 2024 09:05:11 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@57831 git-svn-id: http://core.svn.wordpress.org/trunk@57332 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-textdomain-registry.php | 12 ++++++------ wp-includes/load.php | 1 + wp-includes/version.php | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/wp-includes/class-wp-textdomain-registry.php b/wp-includes/class-wp-textdomain-registry.php index 113ef3bd65..fe6d04b0a1 100644 --- a/wp-includes/class-wp-textdomain-registry.php +++ b/wp-includes/class-wp-textdomain-registry.php @@ -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; } } diff --git a/wp-includes/load.php b/wp-includes/load.php index 40947a0b20..b7bde142ec 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -876,6 +876,7 @@ function wp_start_object_cache() { 'site-queries', 'site-transient', 'theme_files', + 'translation_files', 'rss', 'users', 'user-queries', diff --git a/wp-includes/version.php b/wp-includes/version.php index 1762e61805..8f4665984d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-57829'; +$wp_version = '6.6-alpha-57831'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.