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;