Problem/Motivation

When installing modules or themes, locale module adds a batch to rewrite the configuration added for language and also apply configuration overrides based on locale data. This is theoretically consistent between module and theme install but theme install goes through a regular link/controller instead of a form and never executes the batch locale adds.

Ironically this works for experimental themes because they get a confirm form which does then execute the batch.

While locale's updateDefaultConfigLangcodes() batch is queued by hook_themes_installed it is never executed. The ThemeController::install() action performs the install and then immediately returns a RedirectResponse to system.themes_page — without ever calling batch_process(). As a result, all theme config langcodes remain exactly as shipped regardless of the site default language.

Steps to reproduce

1. Have locale module enabled and a non-English site default language.
2. Manually add a YAML file for a content type to the default_admin theme in core (not installed yet).
3. Install the theme, submit the confirm form.
4. Check in config export that it worked, the config is in the non-English language.

On the other hand, do the same for a non-experimental theme, and the config will not be in the language you expect.

Proposed resolution

Either check for a queued batch in ThemeController::install() after calling $this->themeInstaller->install(), and call batch_process() if one exists, the same way FormSubmitter::doSubmitForm() does or consider moving theme install to a proper form submission so the standard batch-processing path handles it automatically.

Remaining tasks

User interface changes

If we go with the form method, the "install" and "install and set default" features will become a button to submit the form.

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3612163

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

gábor hojtsy created an issue. See original summary.

gábor hojtsy’s picture

Issue summary: View changes

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

nicxvan’s picture

Status: Active » Reviewed & tested by the community

Going to jump to RTBC.

I applied adding a newline so that PHPCS will pass.

Changes look complete, I checked ThemeController for other paths and didn't see anything beyond the mentioned experimental theme confirmation which already handles batches.

I can't run test only so I pulled this down locally to run it, it fails as expected:

There were 2 failures:

1) Drupal\Tests\locale\Functional\LocaleThemeInstallTest::testThemeInstallRewritesConfigLangcode
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'de'
+'en'

/var/www/html/core/modules/locale/tests/src/Functional/LocaleThemeInstallTest.php:67

2) Drupal\Tests\locale\Functional\LocaleThemeInstallTest::testThemeSetDefaultRewritesConfigLangcode
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'de'
+'en'

/var/www/html/core/modules/locale/tests/src/Functional/LocaleThemeInstallTest.php:79
nicxvan’s picture

Component: theme system » extension system

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

nicxvan’s picture

+1 for those new changes, they look more resilient.

alexpott’s picture

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

My changes to runtime code are very small and the test changes are quite small too... therefore I think this is good for me to commit this as I made those changes as part of a review into the code changes.

Committed and pushed c35d842e681 to main and 5c2bdf95033 to 11.x and 2a2ff0e5c4c to 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.

  • alexpott committed 2a2ff0e5 on 11.4.x
    fix: #3612163 When installing themes on the Appearance page, batches...

  • alexpott committed 5c2bdf95 on 11.x
    fix: #3612163 When installing themes on the Appearance page, batches...

  • alexpott committed c35d842e on main
    fix: #3612163 When installing themes on the Appearance page, batches...