Problem/Motivation

  1. Enable any language ('de' for example);
  2. Enable 'content_moderation' module;
  3. Update translations
  4. Export configuration
  5. Import exported configuration on a clean site

I get following error for translation of config ' workflows.workflow.editorial.yml':

TypeError: Argument 5 passed to Drupal\locale\LocaleConfigSubscriber::processTranslatableData() must be of the type array, boolean given, called in /var/www/drupalvm/sites/valeod8/docroot/core/modules/locale/src/LocaleConfigSubscriber.php on line 152 in /var/www/drupalvm/sites/valeod8/docroot/core/modules/locale/src/LocaleConfigSubscriber.php on line 142 #0 /var/www/drupalvm/sites/valeod8/docroot/core/modules/locale/src/LocaleConfigSubscriber.php(152): Drupal\locale\LocaleConfigSubscriber->processTranslatableData('workflows.workf...', Array, Array, 'de', false)

Proposed resolution

This looks to be a bug in LocaleConfigSubscriber::processTranslatableData.

While iterating over the localized config data, it keeps a reference to the original configuration so that the localized configuration serves as an override. However, it was replacing it's reference to $reference_config causing it to reference the wrong value when iterating over multiple keys.

Renaming the variable to avoid overriding the original should fix the problem.

Remaining tasks

  • Write patch
  • Write a test
  • Review

User interface changes

N/A

API changes

None

Data model changes

None

Release notes snippet

TBD?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

validoll created an issue. See original summary.

angel.h’s picture

@validoll did you find a solution for this?

validoll’s picture

@angel.h unfortunately no. Just remove translations of this config.

justclint’s picture

Also ran into this. Removing workflows.workflow.editorial.yml from each translation resolved the error for now.

mediabounds’s picture

Version: 8.4.x-dev » 8.6.x-dev
Status: Active » Needs review
FileSize
980 bytes

I ran into this issue too.
This looks to be a bug in LocaleConfigSubscriber.php in processTranslatableData.

While iterating over the localized config data, it keeps a reference to the original configuration so that the localized configuration serves as an override. However, it was replacing it's reference to $reference_config causing it to reference the wrong value when iterating over multiple keys.

I'm attaching a patch to keep the local reference separate from the original argument.

This bug likely had other manifestations, but workflows configuration was somewhat of a special case (which is what caused the exception):
The default workflows has a "published" state and each state has a "published" property. Because processTranslableData was replacing it's reference to the original configuration, it ended up referencing the wrong "published" property in the config (in this case, a boolean instead of an array, hence the exception).

justclint’s picture

I just tested #5 and it worked great. I can confirm the build including translation workflows.workflow.editorial.yml files completed without the errors now.

Thanks for the patch @mediabounds!

Rob230’s picture

Patch #5 fixes it for me, thanks.

Manuel Garcia’s picture

Issue tags: +Needs tests

Nice work hunting this down @mediabounds!

My guess is this will need tests in order to get in, tagging.

Sharique’s picture

Version: 8.6.x-dev » 8.8.x-dev

+1 for RTBC, the patch fixes the issue for me.

hctom’s picture

Patch from #5 works like a charm, also +1 for RTBC... and do we really need a tests for fixing a new variable accidentally overriding an existing one inside a function?

hctom’s picture

Perhaps I have to revoke my last comment: I applied the patch and from now on, our exported language entities loose their third-party settings (we have disable_language installed and those settings are lost upon export). First config export after fresh install and config import does not export any changes, but as soon as any config in the system is changed and exported, the problem with the lost third-party settings occures :(

Perhaps someone else can also try it with the patch applied, disable_language enabled, some languages configured (with some disabled), so we can be sure if this is a problem with the patch or something else.

Changing my mind back to comment #10 ;) We tracked down the issue with the lost third party settings and it turned out to be a config_filter misconfiguration for the language entity configs.

So from my point of view: good to get it in as soon as possible.

Manuel Garcia’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Thanks for reporting and the information @hctom @Sharique

After thinking about it, I agree this may not need a new test, as it could indeed have other scenarios where this would be affecting and it would be hard to track all down. I'm marking this as RTBC to get feedback from committers around this, other than this, this is a very straight fix and an easy to follow change.

Manuel Garcia’s picture

Issue summary: View changes

Updating the issue summary for clarity and current state of the issue.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Thanks for finding and working out how to fix this bug. The fix looks great but it definitely needs a test. Tests prevent making the same mistake and this goes to show that our current test coverage of \Drupal\locale\LocaleConfigSubscriber::processTranslatableData() is not as complete as it should be.

Lendude’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
4.46 KB
5.41 KB

Here is a test for this. It's a little forced to get the reported error to show.

Test only patch is the interdiff.

The last submitted patch, 15: 2939356-15-TEST_ONLY.patch, failed testing. View results

Manuel Garcia’s picture

Issue summary: View changes

Thanks @Lendude, - just updating the remaining tasks here :)

Lendude’s picture

Lendude’s picture

Interdiff...

Manuel Garcia’s picture

Status: Needs review » Reviewed & tested by the community

I had a look at the test, it makes sense to me, and the test only patch fails with the reported error demonstrating the bug.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Crediting @Manuel Garcia for issue management and review
Crediting @validoll for filing the issue.
Crediting @justclint and @hctom for testing the patch and reporting back

Committed and pushed ea0ab7e57a to 8.8.x and 4de8670ac1 to 8.7.x. Thanks!

  • alexpott committed ea0ab7e on 8.8.x
    Issue #2939356 by Lendude, mediabounds, Manuel Garcia, validoll,...

  • alexpott committed 4de8670 on 8.7.x
    Issue #2939356 by Lendude, mediabounds, Manuel Garcia, validoll,...
vijaycs85’s picture

Title: Fatal error during import translaton of workflows.workflow.editorial.yml config » Fatal error during import translation of workflows.workflow.editorial.yml config

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rzanetti’s picture

FileSize
974 bytes

This patch (2939356-25.patch) fixes the error in the 8.6.x core.

[error] TypeError: Argument 5 passed to Drupal\locale\LocaleConfigSubscriber::processTranslatableData() must be of the type array, string given, called in /app/web/core/modules/locale/src/LocaleConfigSubscriber.php on line 152 in Drupal\locale\LocaleConfigSubscriber->processTranslatableData() (line 142 of /app/web/core/modules/locale/src/LocaleConfigSubscriber.php)

rzanetti’s picture