From ec7d5e5f41935c30e686c2e17906f1c91c471bce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:54:16 +0000 Subject: [PATCH 1/2] Initial plan From 24e37e8d8f4c6f4b4661be7bb75538b81db2c00d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Sep 2026 21:56:39 +0000 Subject: [PATCH 2/2] Use make_temp_file() for cached language downloads Co-authored-by: schlessera <83631+schlessera@users.noreply.github.com> --- features/language-core.feature | 30 +++++++++++++++++++++++++++++ src/WP_CLI/LanguagePackUpgrader.php | 3 +-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/features/language-core.feature b/features/language-core.feature index 027c0b6c..b94541f3 100644 --- a/features/language-core.feature +++ b/features/language-core.feature @@ -220,6 +220,36 @@ Feature: Manage core translation files for a WordPress install """ And the return code should be 0 + @require-wp-4.0 + Scenario: Use cached language file when available + Given a WP install + And an empty cache + + When I run `wp language core install en_GB` + Then STDOUT should contain: + """ + Success: Installed 1 of 1 languages. + """ + And STDERR should be empty + + When I run `wp language core uninstall en_GB` + Then STDOUT should be: + """ + Success: Language uninstalled. + """ + And STDERR should be empty + + When I run `wp language core install en_GB` + Then STDOUT should contain: + """ + Using cached file + """ + And STDOUT should contain: + """ + Success: Installed 1 of 1 languages. + """ + And STDERR should be empty + @require-wp-6.0 @require-php-7.2 Scenario Outline: Core translation update in newer versions Given an empty directory diff --git a/src/WP_CLI/LanguagePackUpgrader.php b/src/WP_CLI/LanguagePackUpgrader.php index 33569667..fa097529 100644 --- a/src/WP_CLI/LanguagePackUpgrader.php +++ b/src/WP_CLI/LanguagePackUpgrader.php @@ -99,8 +99,6 @@ public function download_package( $package, $check_signatures = false, $hook_ext $language = $language_update->language; $ext = pathinfo( $package, PATHINFO_EXTENSION ); - $temp = \WP_CLI\Utils\get_temp_dir() . uniqid( 'wp_' ) . '.' . $ext; - $cache = WP_CLI::get_cache(); $cache_key = "translation/{$type}-{$slug}-{$version}-{$language}-{$updated}.{$ext}"; @@ -110,6 +108,7 @@ public function download_package( $package, $check_signatures = false, $hook_ext $cache_file = $cache->has( $cache_key ); if ( $cache_file ) { + $temp = \WP_CLI\Utils\make_temp_file( 'wp_', '.' . $ext ); WP_CLI::log( "Using cached file '$cache_file'..." ); copy( $cache_file, $temp ); return $temp;