From 2d39c954a26f2a075e1957cb4f8de345b1c00c51 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 15 Mar 2024 11:20:06 +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. 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 --- 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 5a6f68308b..459c9220b2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.