Problem/Motivation

There are several batch callbacks in locale, we should be able to convert them in one go.

#3577671: Modernize locale file handling
#3037031: Convert locale.compare.inc to a service
#3575096: Remove callable type from BatchBuilder ::addOperation and ::setFinishCallback

Steps to reproduce

N/A

Proposed resolution

Mapping

Deprecated procedural callback Replacement
locale_translation_batch_version_check \Drupal::service(LocaleFetch::class)->batchVersionCheck()
locale_translation_batch_status_check \Drupal::service(LocaleFetch::class)->batchStatusCheck()
locale_translation_batch_fetch_download \Drupal::service(LocaleFetch::class)->batchDownload()
locale_translation_batch_fetch_import \Drupal::service(LocaleFetch::class)->batchImport()
locale_translation_batch_fetch_finished \Drupal::service(LocaleFetch::class)->batchFinished()
_locale_translation_batch_status_operations \Drupal::service(LocaleFetch::class)->getStatusOperations()
locale_translate_batch_build \Drupal::service(LocaleImportBatch::class)->buildBatch()
locale_translate_batch_import \Drupal::service(LocaleImportBatch::class)->batchImport()
locale_translate_batch_import_save \Drupal::service(LocaleImportBatch::class)->batchSave()
locale_translate_batch_refresh \Drupal::service(LocaleImportBatch::class)->batchRefresh()
locale_translate_batch_finished \Drupal::service(LocaleImportBatch::class)->batchFinished()
locale_config_batch_update_components \Drupal::service(LocaleConfigBatch::class)->buildBatch()
locale_config_batch_build No replacement it was inlined into LocaleConfigBatch::buildBatch
locale_config_batch_update_default_config_langcodes \Drupal::service(LocaleConfigBatch::class)->batchUpdateDefaultConfigLangcodes()
locale_config_batch_update_config_translations \Drupal::service(LocaleConfigBatch::class)->batchUpdateConfigTranslations()
locale_config_batch_finished \Drupal::service(LocaleConfigBatch::class)->batchFinished()
locale_translation_check_projects_batch \Drupal::service(LocaleProjectChecker::class)->triggerBatch()
locale_translation_batch_status_build No replacement it was inlined into LocaleProjectChecker::batchCheckProjects
locale_translation_batch_status_finished \Drupal::service(LocaleProjectChecker::class)->batchFinished()

Remaining tasks

Review

Update other .inc CRs if any methods changed
fetchOperations -> getFetchOperations
batchFetchBuild -> buildFetchBatch
batchUpdateBuild -> buildUpdateBatch

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

CommentFileSizeAuthor
#10 Screenshot from 2026-05-12 00-39-31.png135.91 KBnicxvan

Issue fork drupal-3581303

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

nicxvan created an issue. See original summary.

nicxvan’s picture

Title: Convert locale batch callbacks » [pp-1] Convert locale batch callbacks
nicxvan’s picture

Title: [pp-1] Convert locale batch callbacks » [pp-3] Convert locale batch callbacks
nicxvan’s picture

Title: [pp-3] Convert locale batch callbacks » [pp-2] Convert locale batch callbacks
nicxvan’s picture

Title: [pp-2] Convert locale batch callbacks » [pp-1] Convert locale batch callbacks
nicxvan’s picture

Title: [pp-1] Convert locale batch callbacks » Convert locale batch callbacks
Status: Postponed » Active
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

locale.batch.inc

locale_translation_batch_version_check -> callback
LocaleFileManager, LocalProjectRepository, KeyValue::locale.translation_status
locale_translation_batch_status_check -> callback
LocaleSource, LocaleFileManager
locale_translation_batch_fetch_download -> callback
LocaleFileManager
locale_translation_batch_fetch_import -> callback
No Dependecies
locale_translation_batch_status_finished -> Finisher
ModuleHandler, Account, TranslationManager, Messenger, State, Time
locale_translation_batch_fetch_finished -> Finisher
State, Time

locale.bulk.inc

locale_config_batch_update_components -> builder builder
LanguageManagerInterface, LocaleConfigManager
locale_translate_batch_build -> builder
No dependendencies
locale_config_batch_build -> builder
LanguageManagerInterface
locale_translate_batch_import -> callback
FileSystemInterface, Logger
locale_translate_batch_import_save -> callback
Time
locale_translate_batch_refresh -> callback
LocaleConfigManager
locale_config_batch_update_default_config_langcodes -> callback ??
LocaleConfigManager, LanguageManagerInterface
locale_config_batch_update_config_translations -> callback
LocaleConfigManager
locale_translate_batch_finished -> Finisher
Logger, ModuleHandler, Account, Messenger, TranslationManager
locale_config_batch_finished -> Finisher
Messenger, Logger

locale.bulk.inc

locale_translation_check_projects_batch -> builder builder
No dependencies
locale_translation_batch_status_build -> builder
LocaleProjectRepository
_locale_translation_batch_status_operations -> operations creator
No dependencies

nicxvan’s picture

StatusFileSize
new135.91 KB

Well this was fun, I built a flow chart of these functions...

berdir’s picture

I think the I would start by pulling in some functions into the existing fetch and checker services, especially fetch already has some batch build related things. They have some other references but as batch callbacks they mostly need to be public anyway and installer is a special case.

The rest has some strange overlaps, I wouldn't split between operations and finisher and instead try to group by a whole batch. Maybe a new service for everything config related and then see what's left?

nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes

nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

nicxvan’s picture

Status: Active » Needs review
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
nicxvan’s picture

Issue summary: View changes
berdir’s picture

Status: Needs review » Reviewed & tested by the community

Once again, the amount of code, functions and features in locale is staggering. This is a massive MR, but unlike several previous locale issues, this is all straightforward. We just convert all those batch related functions almost 1:1 to service methods, either on the existing services that already build those batches and additionally two new ones. A handful of trivial wrapper methods were dropped and inlined. There are no structure changes, no behavior changes.

We had a bunch of discussions on class and method names, I think we are in a good spot with this now.

With this MR, all 5 include files in locale are 100% deprecated, only the functions in locale.module are left.

amateescu made their first commit to this issue’s fork.

  • amateescu committed 0977dec3 on main
    task: #3581303 Convert locale batch callbacks
    
    By: nicxvan
    By: berdir
    By...
amateescu’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Applied a few suggestions to be consistent for the $context signature, then committed 0977dec and pushed to main. Thanks!

Will need a rebase for 11.x :)

nicxvan’s picture

Status: Patch (to be ported) » Reviewed & tested by the community

Ok I pushed up the backport.

There were three conflicts and one legacy test that needed updating.
baseline
services
LocaleConfigSubscriberTest
LocaleBulkDeprecationTest, this doesn't exist in main.

I compared the main commit with the backport and each diff aligns except the services because we had to add autowire: true and the test that is not in main.

LocaleBulkDeprecationTest called a function that was removed from main already so we needed to update it to mock the new LocaleConfigBatch service.

Crediting longwave for pointing out where to look for the failure on 11.x

Never sure on these if I can self RTBC

  • amateescu committed 16e91ba0 on 11.x
    task: #3581303 Convert locale batch callbacks
    
    By: nicxvan
    By: berdir
    By...
amateescu’s picture

Status: Reviewed & tested by the community » Fixed

I think it's fine, I have to review it as well anyway.

Committed 16e91ba and pushed to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

alexpott’s picture

Status: Fixed » Needs work

This has cause fails on the 11.x branch - they don't appear to occur locally but are consistent on CI. See https://git.drupalcode.org/project/drupal/-/pipelines?source=push&scope=...

Reverting from that branch - we also need to understand if the flaw affects main but just is not exposed by main.

  • alexpott committed f927965f on 11.x
    Revert "task: #3581303 Convert locale batch callbacks"
    
    This reverts...

berdir’s picture

Status: Needs work » Reviewed & tested by the community

readonly properties strike again. Worked in 8.5 on the MR, but fails on 8.3 on the commit tests.

I'd suggest we configure 11.x MR pipelines to also run with 8.3, it's much more likely that we break 8.3 than 8.5 I think. And the commit pipelines could run with a mix of 8.3 and 8.5?

MR shows as red, but I can't access the results nor can I run it against 8.3, but I verified that one of the affected tests fails locally and worked with the change on 8.3.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 7bc83d540cb to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 7bc83d54 on 11.x
    task: #3581303 Convert locale batch callbacks
    
    By: nicxvan
    By: berdir
    By...

godotislate made their first commit to this issue’s fork.

godotislate’s picture

Status: Fixed » Needs review

The readonly property in TranslationStatusForm is breaking the 11.x and 11.4.x PHP 8.3 tests.

See
https://git.drupalcode.org/project/drupal/-/pipelines/822383/test_report...
https://git.drupalcode.org/project/drupal/-/pipelines/822386/test_report...
https://git.drupalcode.org/project/drupal/-/pipelines/822388

MR to fix: https://git.drupalcode.org/project/drupal/-/merge_requests/15862

Relatedly, (shameless plug) getting #3548971: Replace PHP soft-deprecated __sleep()/__wakeup() with __serialize()/__unserialize() can help avoid the readonly issues in the future, at least for 11.x. It might be too late for 11.4.x.

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

I guess we still missed one here!

  • catch committed cb21f0e3 on 11.4.x
    task: #3581303 Convert locale batch callbacks
    
    By: nicxvan
    By: berdir
    By...

  • catch committed 90428056 on 11.x
    task: #3581303 Convert locale batch callbacks
    
    By: nicxvan
    By: berdir
    By...
catch’s picture

Version: 11.x-dev » 11.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed the follow-up to 11.x and 11.4.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.