Make WordPress Core

Opened 9 years ago

Closed 10 days ago

Last modified 8 days ago

#42281 closed enhancement (fixed)

Better Update Management for Translation files

Reported by: stk_jj Owned by: audrasjb
Priority: normal Milestone: 7.2
Component: Upgrade/Install Version: 4.8.2
Severity: normal Keywords: has-patch has-unit-tests has-screenshots has-test-info commit
Cc: Focuses:

Description

Codex says:

Automatic translation file updates are already enabled by default, the same as minor core updates.

But still a button "update translations" is shown in the Update Dashboard. This is ridiculous as I

a) have no influence on accepting or skipping a certain translation, because
b) there is no presention of the upcoming translation updates in advance

As we have PTE and GTE for QA autoupdate is the right choice for translation files. Pls consider to remove the "update translations" buttons and substitute it with a email message as per minor core updates.

Attachments (3)

before-11610.png​ (403.3 KB ) - added by ozgursar 2 months ago.
Before PR11610
after-11610.png​ (396.8 KB ) - added by ozgursar 2 months ago.
After PR11610
after-11610.mp4​ (7.5 MB ) - added by ozgursar 2 months ago.
After PR11610

Change History (40)

#1 @Jyria
9 years ago

  • Keywords 2nd-opinion added

Hello there @stk_jj !

Automatic translations updates are in place, if you are facing the following scenario:

  1. Plugin/theme update/s is/are available.

If you click "Update plugins/themes", within the same update routine also a check for newly available translation files (for just installed plugin/theme versions) is performed and installed automatically onto your installtion if available (!) for those currently updated plugins/themes - without having to click "update translations" separately.

  1. WP Core update

Same thing as above

_

Only if translation updates become available at an asynchronous point of time, you will see the "Update translations" button.
And yes, I agree there should be some improvement here:

  1. At least present the user a list of the exact translation files which just became available, with the possibility to NOT install one or all of them (just like available plugins/themes update list)
  2. Even though codex says, that WP should not force anything onto your installation, without your consent by default ( i.e. "update plugins"-button, "update themes"-button), we should take into account that newly available translation files already ran through thorough review, and you already decided to run the corresponding plugin and/or WP core versions in your installation. Thus the admin of the current installation already gave their consent to these code versions (plugin, theme, core). And since translation files should be considered as "part" of the installed plugin/theme/core versions, translation updates should run automatically, just like minor core updates.

Best regards
Saskia

Could you have a look at this?
@ocean90

Last edited 9 years ago by Jyria (previous) (diff)

#2 @Presskopp
9 years ago

related #31902

Version 0, edited 9 years ago by Presskopp (next)

This ticket was mentioned in ​PR #11610 on ​WordPress/wordpress-develop by ​@Jyria.


7 months ago
#3

  • Keywords has-patch has-unit-tests added

## Summary

list_translation_updates() currently renders only a generic "New translations are available." message and the Update Translations button. Unlike the WordPress core, plugin, and theme update sections, it does not resolve or display the specific translation updates that are pending, so there is no pre-upgrade visibility into which component/language/version combinations will be updated.

This PR adds display helpers for translation updates and uses them on update-core.php to list the pending translation updates before the upgrade runs.

## Changes

  • add translation update display helpers in wp-admin/includes/update.php
  • resolve translation update names for core, themes, and plugins
  • map plugin translation slugs back to installed plugin files so WordPress.org-style slugs still display the correct plugin name
  • display a translations count and a per-update list on wp-admin/update-core.php
  • add PHPUnit coverage for translation update display data, including plugin slug fallback behavior

## Test plan

  • [x] php -l src/wp-admin/includes/update.php
  • [x] php -l src/wp-admin/update-core.php
  • [x] php -l tests/phpunit/tests/admin/includesUpdate.php
  • [x] vendor/bin/phpcs --standard=phpcs.xml.dist src/wp-admin/includes/update.php src/wp-admin/update-core.php tests/phpunit/tests/admin/includesUpdate.php
  • [x] Authenticated HTTP smoke test against https://wpcore.wp-studio.dev/wp-admin/update-core.php with a temporary MU-plugin fixture injecting controlled core, plugin, and theme translation updates; verified the rendered translations section shows a count of 3 and entries for WordPress, Hello Dolly, and Twenty Twenty-Four
  • [ ] PHPUnit execution for Tests_Admin_IncludesUpdate could not be run in this environment because the local WordPress test configuration / Docker test environment was unavailable

## Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5-based Codex
Used for: implementation, test scaffolding, server-side smoke-test orchestration, and PR drafting; outputs were reviewed and validated with syntax checks, PHPCS, and an authenticated admin-page smoke test.

#4 @Jyria
7 months ago

Refreshing this ticket with a patch for the UI improvement mentioned in comment:1.

PR: ​https://github.com/WordPress/wordpress-develop/pull/11610

This patch keeps the current translation update behavior, but improves the Updates screen by listing the specific pending translation updates before the upgrade runs. It adds display data helpers for translation updates and renders the pending core/plugin/theme translation packages with component name, language, and target version on wp-admin/update-core.php.

Tests/validation:

  • Added PHPUnit coverage for the translation update display data, including plugin slug mapping for WordPress.org-style slugs.
  • Passed php -l on the changed files.
  • Passed phpcs for the changed files.
  • Ran an authenticated admin smoke test against update-core.php on a dedicated test instance and verified the rendered translations section and count for core, plugin, and theme translation updates.

I was not able to run the PHPUnit suite end-to-end in this environment because the local WordPress test configuration / Docker test environment was unavailable.

However I manually tested this using WP playground: ​https://github.com/WordPress/wordpress-develop/pull/11610#issuecomment-4287467328

https://isla-stud.io/img_cloud/wordpress_trac_pr_11610.png

Last edited 7 months ago by Jyria (previous) (diff)

​@Jyria commented on ​PR #11610:


7 months ago
#5

Playground test passed. Manually tested and reviewed. Works.

​Test this pull request with WordPress Playground.

#6 @Jyria
7 months ago

  • Summary No Autoupdate for Translation files → Better Update Management for Translation files
  • Type defect (bug) → enhancement

#7 @Jyria
7 months ago

  • Keywords has-screenshots added; 2nd-opinion removed

Ticket Properties modified to better reflect its status.

​@Jyria commented on ​PR #11610:


6 months ago
#8

Quick note on the remaining failing PHPUnit jobs in the current run:

  • PHP 8.1 / MariaDB 11.4 fails during npm run env:install with Database connection error (2002) Connection refused.
  • PHP 8.0 / MariaDB 11.8 fails during gutenberg:verify while downloading the Gutenberg artifact with Download/extraction failed: fetch failed.

These both appear to be CI/infrastructure issues rather than failures caused by the translation update changeset. The other workflows for the current head are passing, and the targeted syntax, PHPCS, smoke, and E2E validation for this patch remain green.

Happy to take another look if either failure reproduces consistently on a rerun.

#9 @Jyria
5 months ago

Refreshing this ticket for review.

PR: ​https://github.com/WordPress/wordpress-develop/pull/11610

Since the last update:

  • the branch has been rebased onto current trunk
  • the review feedback about guarding deferred checks / avoiding repeated lookups has been addressed
  • a refreshed branch was pushed so GitHub CI is now running again on the current head

Targeted syntax checks, PHPCS, and the manual/E2E validation for the update-core.php flow remain green here.

Re-adding needs-testing for the refreshed patch.

This ticket was mentioned in ​Slack in #core by jyria. ​View the logs.


5 months ago

#11 @Jyria
4 months ago

  • Keywords needs-testing added

​@Jyria commented on ​PR #11610:


4 months ago
#12

@tfrommen The branch is now rebased to current trunk. Your previous review feedback remains addressed, and I also fixed the two subsequent automated review findings in ea96b2200d. The current head passes all 229 applicable checks, including the full PHPUnit matrix and both E2E runs. If you have bandwidth for another look, I would appreciate it. Thank you!

This ticket was mentioned in ​Slack in #core-upgrade-install by jyria. ​View the logs.


4 months ago

This ticket was mentioned in ​Slack in #core by jyria. ​View the logs.


2 months ago

#15 @audrasjb
2 months ago

  • Milestone Awaiting Review → 7.2
  • Owner set to audrasjb
  • Status new → reviewing

Moving for 7.2 consideration.

#16 @ozgursar
2 months ago

Test Report

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/11610

Environment

  • WordPress: 7.2-alpha-63166-src
  • Subdirectory: No
  • PHP: 8.4.23
  • Server: nginx/1.29.4
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.4.23)
  • Browser: Chrome 152.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins:
    • docker-loopback-fix.php
    • fake-translation-updates.php
  • Plugins:
    • Test Reports 1.3.1

Steps taken

  1. Add the following snippet as fake-translation-updates.php to your /wp-content/mu-plugins/ to add fake translation updates
<?php
/**
 * Fakes pending translation updates on the Updates screen for local testing,
 * without requiring a real check against api.wordpress.org.
 */

function fake_translation_updates_inject( $value, $type, $slug, $version ) {
        if ( ! is_object( $value ) ) {
                $value = new stdClass();
        }

        if ( ! isset( $value->translations ) || ! is_array( $value->translations ) ) {
                $value->translations = array();
        }

        $value->translations[] = array(
                'type'     => $type,
                'slug'     => $slug,
                'language' => 'de_DE',
                'version'  => $version,
                'updated'  => gmdate( 'Y-m-d H:i:s' ),
                'package'  => '',
        );

        return $value;
}

add_filter(
        'site_transient_update_core',
        function ( $value ) {
                return fake_translation_updates_inject( $value, 'core', 'default', get_bloginfo( 'version' ) );
        }
);

add_filter(
        'site_transient_update_plugins',
        function ( $value ) {
                return fake_translation_updates_inject( $value, 'plugin', 'hello', '1.7.2' );
        }
);

add_filter(
        'site_transient_update_themes',
        function ( $value ) {
                return fake_translation_updates_inject( $value, 'theme', 'twentytwentyfive', '1.2' );
        }
);

  1. Go to /wp-admin/update-core.php
  2. Observe the Translations heading displays "New translations are available." message and "Update Translations" button
  3. Apply the patch
  4. View /wp-admin/update-core.php again
  5. Observe the Translations heading now displaying each translation individually with checkboxes
  6. ✅ Patch is solving the problem

Expected result

  • Users should be able to select/deselect which translations to update.

Additional Notes

  • mu-plugin for faking translation updates is created using Claude Sonnet 5.

Screenshots/Screencast with results

Before
https://core.trac.wordpress.org/raw-attachment/ticket/42281/before-11610.png

After
https://core.trac.wordpress.org/raw-attachment/ticket/42281/after-11610.png

#17 @Jyria
2 months ago

Thanks @ozgursar for testing this and adding the before/after screenshots!

If you have time for another pass, it would be helpful to try it with real translation updates too: leave one unchecked, install the selected updates, then revisit the Updates screen. The deferred update should still be listed and available to select and install later. It should also be skipped by background translation updates and by the translation updates that run after a plugin or theme upgrade.

Your snippet is useful for checking the UI. Since the package URLs are empty, testing with real packages would help cover the installation and deferral behaviour as well.

#18 @ozgursar
2 months ago

@Jyria I would like to test the real translation updates but I couldn't find a proper way to trigger them other than the snippet I've posted. Could you please guide me on testing steps?

#19 @Jyria
2 months ago

@ozgursar Sure, and thanks for taking another look!

On your test installation, remove the fake-update snippet first. Install a few plugins with German translations available, such as Yoast SEO, then go to Settings → General, change Site Language to Deutsch, and save.

You can keep your own dashboard in English by selecting English under Users → Profile → Language. That won't change the site's language.

Next, go to Dashboard → Updates and click “Check again”. If translation updates appear, leave one unchecked and install the others. Revisit the page to check that the unchecked translation is still available, then select it and install it.

One catch: WordPress may already have installed the translations automatically, so changing the language alone doesn't guarantee pending updates. If everything is already up to date, let me know and I'll help you set up a reproducible test with real translation packages.

plus:
I recorded a short walkthrough using the Playground link from this ticket:

​https://cloud.wp-studio.dev/s/w3QzH3oeGdpBroR

I installed Yoast SEO and Contact Form 7, switched the site language to German, then Spanish, and back to German. I kept my own dashboard in English via the language setting in my user profile.

In this run, that produced 30 real translation updates. The video shows me leaving four unchecked, installing the selected updates, and returning to the Updates screen, where those four are still listed.

Hopefully this makes the setup easier to follow. Thanks again for testing!

#20 @ozgursar
2 months ago

  • Keywords has-test-info added; needs-testing removed

@Jyria please find my new test report and screen capture based on your test instructions:

Test Report

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/11610

Environment

  • WordPress: 7.2-alpha-63166-src
  • Subdirectory: No
  • PHP: 8.4.23
  • Server: nginx/1.29.4
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.4.23)
  • Browser: Chrome 152.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins:
    • docker-loopback-fix.php
  • Plugins:
    • Contact Form 7 6.1.7
    • Test Reports 1.3.1
    • Yoast SEO 28.5

Steps taken

  1. Install a few plugins and themes (I installed Yoast and CF7 in my test) as well as default themes from WordPress Develop repo were present in my /wp-content/themes/ folder
  2. Add a few languages from Settings > General by changing Site Language and saving settings. (I added DE and ES)
  3. Go to Dashboard > Updates
  4. Observe the Translations heading. Confirm that there is a single button to update
  5. Apply patch
  6. Go to Dashboard > Updates
  7. Observe the checkboxes next to each translation for each theme or plugin
  8. Deselect some of them and let the others update
  9. Repeat the process to ensure installed translation updates don't get listed again
  10. ✅ Patch is solving the problem

Expected result

  • We should be able to select/deselect which translations to update

Screenshots/Screencast with results

Before
https://core.trac.wordpress.org/raw-attachment/ticket/42281/before-11610.png

After
https://core.trac.wordpress.org/raw-attachment/ticket/42281/after-11610.mp4

#21 @Jyria
2 months ago

Thanks @ozgursar for testing again with real translation updates and recording the results! Good to see that selecting updates works and that installed translations don't reappear on the next pass.

@audrasjb With the successful test report in comment:20, could you take a look at the code in ​https://github.com/WordPress/wordpress-develop/pull/11610 when you have time? The report covers the manual update flow; background translation updates weren't explicitly tested in this pass.

This ticket was mentioned in ​Slack in #core by im3dabasia1. ​View the logs.


4 weeks ago

#23 @im3dabasia1
4 weeks ago

  • Milestone 7.2 → 7.3

As per today’s 7.2 bug scrub:

The ​/ PR isn’t approved yet and there’s been little recent activity on it, and beta 1 is close, so I’m moving this to 7.3. Feel free to move it back if it needs to be in this milestone.

#24 @Jyria
4 weeks ago

  • Milestone 7.3 → 7.2

@im3dabasia1 Thanks for the update. I understand the concern about the approaching beta, but I’d like to clarify that this contribution has been waiting for code review, rather than being abandoned.

The patch received a successful test report using real translation packages in comment:20, and I asked @audrasjb for code review in comment:21 four weeks ago. That report covers the manual update flow, not background translation updates.

@audrasjb Could you clarify what still needs to be addressed before approval, and whether you have time to review the PR? If not, could another reviewer help? @tfrommen ?

It’s frustrating to see this move to another release without actionable feedback after the implementation and testing work. I’m happy to address specific findings; what would help now is a concrete review and a clear path forward.

#25 @im3dabasia1
4 weeks ago

Thank you @Jyria for your patience and all the work you’ve put into this. It’s good to have it back in 7.2.

@audrasjb, with beta 1 getting close, would you be able to take a look at the PR in the next few days? @tfrommen, if you have time, your help as a reviewer would be really appreciated too. Thank you both so much!

#26 @tfrommen
4 weeks ago

@Jyria @im3dabasia1 I just reviewed the PR again and left some feedback.

​@Jyria commented on ​PR #11610:


4 weeks ago
#27

Thanks for another look, @tfrommen. I've pushed the follow-up in d9930c0b8a.

  • Selection handling now lives in wp_process_translation_update_selection(), with tests for stale IDs, updates outside the form, all-unchecked submissions and the stored deferrals. Capability and nonce checks remain in the controller.
  • The transient test compares one plugin row with ten, rather than expecting a fixed read count. Separate cases cover no updates and core/theme-only updates.
  • The new @since annotations use 7.2.0, our intended release. Requests without valid form IDs still do nothing rather than falling back to installing everything.

The PHPDoc now explains that explicit updates, including WP-CLI, bypass deferral. I've also added a small cleanup in the shared language-pack upgrader: successful installations clear only their matching deferrals; failed and unattempted packages remain deferred. This prevents a completed update's deferral from holding back a later translation revision for the same component version. No new CLI commands or flags are included. The Dev Note draft covers these semantics too.

Local validation:

  • PHP 8.3: 80 tests, 166 assertions across the affected admin classes.
  • PHP 8.1, PHP 8.4 and PHP 8.3 Multisite: the ticket group passes with 35 tests and 96 assertions each.
  • 21 WP-CLI scenarios and seven Firefox E2E tests pass, including failed downloads, partial success, retries and Admin selection. WPCS and syntax checks pass.

The installer tests use synthetic language packs. Background-update coverage is PHPUnit, not cron E2E. Chromium's earlier actionability hang remains unverified. GitHub CI for this commit is separate from these local results.

This ticket was mentioned in ​Slack in #core by audrasjb. ​View the logs.


2 weeks ago

​@audrasjb commented on ​PR #11610:


2 weeks ago
#29

I tested the proposed PR on my side and it looks like it works very well. I'm gonna commit it before beta 3 so we can test it live.

#30 @audrasjb
2 weeks ago

  • Keywords commit added

Self assigning for final code review and commit.

​@Jyria commented on ​PR #11610:


2 weeks ago
#31

@propsbot refresh

#32 @audrasjb
10 days ago

  • Resolution → fixed
  • Status reviewing → closed

In 65226:

Upgrade/Install: Show and allow to select translation updates on the Updates screen.

This changeset introduces a way to see each available translation update on the Updates screen, and allows users to update them selectively. With this change, translation updates management is more consistent with how plugin and theme updates are managed.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/11610.

Props stk_jj, Presskopp, jyria, tfrommen, audrasjb, ozgursar, im3dabasia1.
Fixes #42281.

#33 @audrasjb
10 days ago

In 65227:

Coding Standards: Fix a blank line WPCS issue found after [65226].

See #42281.

This ticket was mentioned in ​PR #15506 on ​WordPress/wordpress-develop by ​@ravipatel.


9 days ago
#34

Follow-up to [65226].

Summary

test_should_update_should_skip_deferred_translation_updates() calls WP_Automatic_Updater::should_update(), which creates an Automatic_Upgrader_Skin. tests/phpunit/tests/admin/wpAutomaticUpdater.php only loads class-wp-automatic-updater.php, so when the file runs on its own the test errors:

1) Tests_Admin_WpAutomaticUpdater::test_should_update_should_skip_deferred_translation_updates
Error: Class "Automatic_Upgrader_Skin" not found

The full suite passes only because earlier tests load class-wp-upgrader.php first. This loads it in set_up_before_class(). Test-only change.

Testing

  • Before: npm run test:php -- tests/phpunit/tests/admin/wpAutomaticUpdater.php: 60 tests, 1 error (single site and multisite).
  • After: OK (60 tests, 99 assertions) on single site and multisite.
  • phpcs: no issues.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Running the commit's tests in isolation and on multisite, finding the missing class load, and drafting this description. I reviewed the change and confirmed the test fails before and passes after.

#35 @ravipatel
9 days ago

Follow-up to [65226]: test_should_update_should_skip_deferred_translation_updates() errors when tests/phpunit/tests/admin/wpAutomaticUpdater.php runs on its own:

Error: Class "Automatic_Upgrader_Skin" not found

WP_Automatic_Updater::should_update() creates an Automatic_Upgrader_Skin, but the test file only loads class-wp-automatic-updater.php. The full suite passes because earlier tests load class-wp-upgrader.php first.

PR ​https://github.com/WordPress/wordpress-develop/pull/15506 loads class-wp-upgrader.php in set_up_before_class(). With it, the file passes on its own on single site and multisite (60 tests). Test-only change.

#36 @lancewillett
8 days ago

In 65277:

Tests: Load the WP_Upgrader classes in the WP_Automatic_Updater tests.

test_should_update_should_skip_deferred_translation_updates() calls WP_Automatic_Updater::should_update(), which creates an Automatic_Upgrader_Skin. The test class loaded only class-wp-automatic-updater.php, so the test errored when its file ran on its own. The full suite passed only because earlier tests had already loaded class-wp-upgrader.php.

Follow-up to [65226].

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/15506

Props ravipatel.
See #42281.

Note: See TracTickets for help on using tickets.