From f45edbe2fec1565bf008d86175ee8c79d2e90161 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Mon, 7 Apr 2014 18:10:09 +1000 Subject: [PATCH] U4-4629 - Detecting existing macros By setting the ID of the macro the repository layer will update the existing instance rather than trying to create a new one, which would result in a duplicate alias and that violates a table index. --- src/Umbraco.Core/Services/PackagingService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index 3187fb9bdd..252932ecfc 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -1196,6 +1196,10 @@ namespace Umbraco.Core.Services foreach (var macro in macros) { + var existing = _macroService.GetByAlias(macro.Alias); + if (existing != null) + macro.Id = existing.Id; + _macroService.Save(macro, userId); } @@ -1820,4 +1824,4 @@ namespace Umbraco.Core.Services public static event TypedEventHandler> ExportedTemplate; #endregion } -} \ No newline at end of file +}