Problem/Motivation

#3218674: "Translation file not found" for English when "translate_english" is false stopped the remote check for English translation files when the remote URI uses the default server pattern. drupal.org does not provide English translations, so every request returns 404.

#3577671: Modernize locale file handling changed the status check. The HTTP request now occurs before the $failure check. The flag only prevents that the result is saved. Thus Drupal sends a HEAD request for each project again and logs a notice for each 404:

[notice] Translation file not found: https://ftp.drupal.org/files/translations/all/views_bulk_operations/views_bulk_operations-4.4.9.en.po.

Affected code in LocaleFetch::batchStatusCheck():

$remoteFileInfo = $this->localeFileManager->checkRemoteFileStatus($remote_file->uri);
  if (!$failure && $remoteFileInfo->status !== RemoteFileStatus::Error) {

The test LocaleBatchTest::testEnglishTranslationSkipsDefaultPattern() did not detect the regression. It only checks that the project is in failed_files. A 404 response gives the same result.

The affected code is the same in main, 12.0.x, 11.x and 11.4.x.

Steps to reproduce

  1. Install Drupal 11.4.x with the Locale module and English as a language. Keep "Enable interface translation to English" disabled.
  2. Add contributed modules, or check for translation updates.
  3. Look at the recent log messages. There is one "Translation file not found" notice for each project with an .en.po URI.

Proposed resolution

  • Do not call checkRemoteFileStatus() when $failure is TRUE.
  • Extend the kernel test: mock LocaleFileManager and make sure that checkRemoteFileStatus() is not called for English with the default server pattern.

MR !16906 in #3619842: Translation install and update batch does a HEAD and then a GET request for every project unnecessarily contains the same change as part of a larger task. This issue fixes the regression separately so that the fix can be backported.

Remaining tasks

  • Create a MR against main.
  • Review.
  • Cherry-pick to 12.0.x, 11.x and 11.4.x.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

Issue fork drupal-3631576

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tobiasb created an issue. See original summary.

tobiasb’s picture

Title: Regression: #3577671 sends HEAD requests for English translation files again » Locale requests English translation files from drupal.org again
Issue summary: View changes

tobiasb’s picture

Assigned: tobiasb » Unassigned
Status: Active » Needs review
tobiasb’s picture

Issue summary: View changes