Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions features/language-core.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/WP_CLI/LanguagePackUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}";

Expand All @@ -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;
Expand Down