Skip to content

Commit

Permalink
Check if language has changed when updating domains (#17790)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeegaan authored Dec 12, 2024
1 parent 4f6fda7 commit 64982a1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Umbraco.Core/Services/DomainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 64982a1

Please sign in to comment.