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
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | Screenshot from 2026-05-12 00-39-31.png | 135.91 KB | nicxvan |
Issue fork drupal-3581303
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
Comment #2
nicxvan commentedComment #3
nicxvan commentedComment #4
nicxvan commentedComment #5
nicxvan commentedComment #6
nicxvan commentedComment #7
nicxvan commentedComment #8
nicxvan commentedComment #9
nicxvan commentedlocale.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
Comment #10
nicxvan commentedWell this was fun, I built a flow chart of these functions...
Comment #11
berdirI 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?
Comment #12
nicxvan commentedComment #13
nicxvan commentedComment #14
nicxvan commentedComment #16
nicxvan commentedComment #17
nicxvan commentedComment #18
nicxvan commentedComment #19
nicxvan commentedComment #20
nicxvan commentedComment #21
nicxvan commentedComment #22
nicxvan commentedComment #23
nicxvan commentedComment #24
nicxvan commentedComment #25
nicxvan commentedComment #26
berdirOnce 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.
Comment #29
amateescu commentedApplied a few suggestions to be consistent for the
$contextsignature, then committed 0977dec and pushed to main. Thanks!Will need a rebase for 11.x :)
Comment #31
nicxvan commentedOk 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
Comment #33
amateescu commentedI think it's fine, I have to review it as well anyway.
Committed 16e91ba and pushed to 11.x. Thanks!
Comment #37
alexpottThis 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.
Comment #40
berdirreadonly 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.
Comment #41
alexpottCommitted and pushed 7bc83d540cb to 11.x. Thanks!
Comment #47
godotislateThe 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.
Comment #48
nicxvan commentedI guess we still missed one here!
Comment #51
catchCommitted/pushed the follow-up to 11.x and 11.4.x, thanks!