diff --git a/src/Umbraco.Core/Services/DomainService.cs b/src/Umbraco.Core/Services/DomainService.cs index 202d51d64874..03ebac92c5a8 100644 --- a/src/Umbraco.Core/Services/DomainService.cs +++ b/src/Umbraco.Core/Services/DomainService.cs @@ -108,7 +108,7 @@ public IEnumerable GetAssignedDomains(int contentId, bool includeWildca EventMessages eventMessages = EventMessagesFactory.Get(); IDomain[] domains = items.ToArray(); - if (domains.Length == 0) + if (domains.Length == 0 || AreDomainsAlreadySorted(domains)) { return OperationResult.Attempt.NoOperation(eventMessages); } @@ -144,4 +144,18 @@ public IEnumerable GetAssignedDomains(int contentId, bool includeWildca return OperationResult.Attempt.Succeed(eventMessages); } + + private static bool AreDomainsAlreadySorted(IDomain[] domains) + { + // Check if the domains are already sorted by comparing the current sort order with what we'll set to be the new sort order. + for (int i = 0; i < domains.Length; i++) + { + if (domains[i].SortOrder != i) + { + return false; + } + } + + return true; + } }