From 64982a1afdf4626a5d67408477aae9d8145f7007 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Thu, 12 Dec 2024 08:47:35 +0100 Subject: [PATCH] Check if language has changed when updating domains (#17790) --- src/Umbraco.Core/Services/DomainService.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Core/Services/DomainService.cs b/src/Umbraco.Core/Services/DomainService.cs index c527e40b8240..58f776a45a56 100644 --- a/src/Umbraco.Core/Services/DomainService.cs +++ b/src/Umbraco.Core/Services/DomainService.cs @@ -311,12 +311,17 @@ private IDomain[] CalculateNewAssignedDomains(int contentId, DomainsUpdateModel var sortOrder = 0; foreach (DomainModel domainModel in updateModel.Domains) { - IDomain assignedDomain = currentlyAssignedDomains.FirstOrDefault(domain => domainModel.DomainName.InvariantEquals(domain.DomainName)) - ?? new UmbracoDomain(domainModel.DomainName) - { - LanguageId = languageIdByIsoCode[domainModel.IsoCode], - RootContentId = contentId - }; + IDomain? assignedDomain = currentlyAssignedDomains.FirstOrDefault(domain => domainModel.DomainName.InvariantEquals(domain.DomainName)); + + // If we do not have an assigned domain, or the domain-language has been changed, create new domain. + if (assignedDomain is null || assignedDomain.LanguageId != languageIdByIsoCode[domainModel.IsoCode]) + { + assignedDomain = new UmbracoDomain(domainModel.DomainName) + { + LanguageId = languageIdByIsoCode[domainModel.IsoCode], + RootContentId = contentId + }; + } assignedDomain.SortOrder = sortOrder++; newAssignedDomains.Add(assignedDomain);