Skip to content

Honor --locale in wp core update and allow locale-change without --force#310

Merged
swissspidy merged 4 commits intomainfrom
copilot/fix-wp-checksum-locale-issue
Feb 25, 2026
Merged

Honor --locale in wp core update and allow locale-change without --force#310
swissspidy merged 4 commits intomainfrom
copilot/fix-wp-checksum-locale-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

wp core update silently ignored --locale when used with --minor or without --version, and required --force to switch locale when the version was already current. This meant users couldn't switch a German WordPress install back to English without wp core update --version=X.Y.Z --locale=en_US --force.

Changes

  • No-version/--minor path: When --locale is explicitly passed, creates a new update object overriding the transient locale and download URL with the requested locale. Previously, the locale from the WordPress.org update transient was always used.

  • Version-specific condition: Added || ! empty( $assoc_args['locale'] ) so that specifying --version=X.Y.Z --locale=<different> on an already-installed version no longer silently exits as "up to date" — the update object is now constructed and the locale change is applied.

  • Execution condition: Added a locale comparison so the update proceeds whenever the requested locale differs from wp_local_package in version.php, even when the version number matches:

    || ( $update->locale ?: 'en_US' ) !== ( self::get_wp_details()['wp_local_package'] ?: 'en_US' )
  • PHPDoc: Expanded the @var annotation for the $from_api transient object to include response, download, and packages properties (required for PHPStan level 9 since the new code reads those properties).

Example

# Previously required --force; now works as expected
wp core update --version=6.5.5 --locale=en_US

# --locale is now honoured in the --minor path
wp core update --minor --locale=en_US

A Behat scenario is added to cover the same-version locale-switch case: downloads 6.5 as de_DE, then updates to en_US on the same version without --force and asserts the package language changes.

Original prompt

This section details on the original issue you should resolve

<issue_title>wp update checksum locale issue</issue_title>
<issue_description>I have a bunch of machines which have been updated to the latest 4.9.7 release. These machines have a cronjob which daily executes this:

wp core update --minor

These machines also have the German locale pack installed. In order to prevent security issues we also check the ckecksum every hour:

/usr/local/bin/wp checksum core

Recently the update bump wordpress release from 4.9.8 to 4.9.7. Unfortunately all machine showed checksum errors because the wp-config-sample.conf had German content.

I haven't been able to reproduce this. Replacing the wp-config-sample.conf from the English wordpress release fixed it.

Funny enough you cannot force an update to the English installation once you have the German locale pack installed:

www-data@<some-host>:/data/backend/wordpress$ /usr/local/bin/wp core update --locale=en_US
Updating to version 4.9.7 (de_DE)...
PHP Warning:  mkdir(): Permission denied in phar:///usr/local/bin/wp/php/WP_CLI/FileCache.php on line 265
Warning: mkdir(): Permission denied in phar:///usr/local/bin/wp/php/WP_CLI/FileCache.php on line 265
Herunterladen der Aktualisierung von https://downloads.wordpress.org/release/de_DE/wordpress-4.9.7.zip …
Entpacken der aktualisierten Version …
Success: WordPress updated successfully.
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@schlessera</author><body>
@runningman84 I ran some tests with the `--locale` flag.

It seems to work if you use both a specific version ( `--version=4.9.7` )  and add the `--force` flag.

This seems to be a bug in the parameter parsing logic, that should either be smarter about how to trigger the update, or give a warning that the `--force` flag or a specific version is needed.</body></comment_new>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ates without --force

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix WP update checksum locale issue Honor --locale in wp core update and allow locale-change without --force Feb 25, 2026
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy swissspidy requested a review from Copilot February 25, 2026 19:31
@swissspidy swissspidy added the command:core-update Related to 'core update' command label Feb 25, 2026
@swissspidy swissspidy added this to the 2.1.24 milestone Feb 25, 2026
@swissspidy swissspidy marked this pull request as ready for review February 25, 2026 19:31
@swissspidy swissspidy requested a review from a team as a code owner February 25, 2026 19:31

This comment was marked as resolved.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy merged commit 9850529 into main Feb 25, 2026
60 checks passed
@swissspidy swissspidy deleted the copilot/fix-wp-checksum-locale-issue branch February 25, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:core-update Related to 'core update' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wp update checksum locale issue

3 participants