Skip to content

fix: Remove null caching for invalid language lookup#196

Open
PantherX99 wants to merge 4 commits into
shopware:trunkfrom
PantherX99:languagelookupFix
Open

fix: Remove null caching for invalid language lookup#196
PantherX99 wants to merge 4 commits into
shopware:trunkfrom
PantherX99:languagelookupFix

Conversation

@PantherX99
Copy link
Copy Markdown

Stop caching null values for languages because they might get created afterwards in the converters.

If null values are cached, converters are using inconsistent data.

Example:

  1. LanguageConverter looks up language with locale ro-RO -> not found -> null gets cached for this locale
  2. LanguageConverter creates this language
  3. SalesChannelConverter uses the languageLookup again, but the cache still resolves to null even though a language was created by the LanguageConverter
  4. Language is not assigned to SalesChannel -> Customers are getting migrated to a sales channel that do not have their language assigned -> migration fails

An different solution would be calling $this->languageLookup->reset(); after the langauge was created in the LanguageConverter. Then all languages would need to be cached again. This has to be called everywhere, when a new language is created. I would think, having invalid locales is highly unlikely, so not caching null values would not result in performance issues.

Stop caching null values for languages because they might get created afterwards in the converters.
@PantherX99
Copy link
Copy Markdown
Author

This also applies to the TranslationConverter in which translations are not being created due to a null value from the languageLookup

@jozsefdamokos
Copy link
Copy Markdown
Member

PantherX99 thanks for this one too 👍 Can you add a test?

@PantherX99
Copy link
Copy Markdown
Author

Jozsef Damokos (@jozsefdamokos) Like this?
I wonder why no one had these issues before and reported them. Did they all started from scratch instead of migrating or did they not use any other language than German and English?

Comment thread tests/Migration/Mapping/Lookup/LanguageLookupTest.php Outdated
Comment thread tests/Migration/Mapping/Lookup/LanguageLookupTest.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution A PR contributed by a community member.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants