diff --git a/src/Migration/Mapping/Lookup/LanguageLookup.php b/src/Migration/Mapping/Lookup/LanguageLookup.php index 4204c422a..2704726cb 100644 --- a/src/Migration/Mapping/Lookup/LanguageLookup.php +++ b/src/Migration/Mapping/Lookup/LanguageLookup.php @@ -57,8 +57,6 @@ public function get(string $localeCode, Context $context): ?string $language = $this->getLanguage($localeUuid, $context); if (!$language instanceof LanguageEntity) { - $this->cache[$localeCode] = null; - return null; } diff --git a/tests/Migration/Mapping/Lookup/LanguageLookupTest.php b/tests/Migration/Mapping/Lookup/LanguageLookupTest.php index d77c692c8..35ab34c59 100644 --- a/tests/Migration/Mapping/Lookup/LanguageLookupTest.php +++ b/tests/Migration/Mapping/Lookup/LanguageLookupTest.php @@ -58,6 +58,55 @@ public function testGetShouldGetDataFromCache(string $localeCode, ?string $expec static::assertSame($expectedResult, $documentTypeLookup->get($localeCode, Context::createDefaultContext())); } + public function testGetDoesNotCacheMissingLanguage(): void + { + $context = Context::createDefaultContext(); + + $languageRepository = static::getContainer()->get('language.repository'); + $localeRepository = static::getContainer()->get('locale.repository'); + + $localeId = Uuid::randomHex(); + $localeCode = 'zz-ZZ'; + $languageId = Uuid::randomHex(); + + try { + $localeRepository->create([ + [ + 'id' => $localeId, + 'code' => $localeCode, + 'name' => 'Test Locale', + 'territory' => 'Test Territory', + ], + ], $context); + + $languageLookup = new LanguageLookup( + $languageRepository, + new LocaleLookup($localeRepository) + ); + + static::assertNull($languageLookup->get($localeCode, $context)); + + $languageRepository->create([ + [ + 'id' => $languageId, + 'name' => 'Test language', + 'localeId' => $localeId, + 'translationCodeId' => $localeId, + ], + ], $context); + + static::assertSame($languageId, $languageLookup->get($localeCode, $context)); + } finally { + $languageRepository->delete([ + ['id' => $languageId], + ], $context); + + $localeRepository->delete([ + ['id' => $localeId], + ], $context); + } + } + #[DataProvider('getLanguageIdData')] public function testGetDefaultLanguageEntity(string $languageId, ?string $expectedResult): void {