Fix Importing Macro when macro already exists
ParseMacroElement called by ImportMacro was no checking for to see if the macro or properties already exists - caused SQL errors on import of macro. Added check to look for existing macro, and only add new properties on import (in line with other import methods)
This commit is contained in:
@@ -1244,7 +1244,8 @@ namespace Umbraco.Core.Services
|
||||
dontRender = bool.Parse(dontRenderElement.Value);
|
||||
}
|
||||
|
||||
var macro = new Macro(macroAlias, macroName, controlType, controlAssembly, xsltPath, scriptPath,
|
||||
var existingMacro = _macroService.GetByAlias(macroAlias) as Macro;
|
||||
var macro = existingMacro ?? new Macro(macroAlias, macroName, controlType, controlAssembly, xsltPath, scriptPath,
|
||||
cacheByPage, cacheByMember, dontRender, useInEditor, cacheDuration);
|
||||
|
||||
var properties = macroElement.Element("properties");
|
||||
@@ -1262,6 +1263,7 @@ namespace Umbraco.Core.Services
|
||||
sortOrder = int.Parse(sortOrderAttribute.Value);
|
||||
}
|
||||
|
||||
if (macro.Properties.Any(x => x.Alias == propertyAlias)) continue;
|
||||
macro.Properties.Add(new MacroProperty(propertyAlias, propertyName, sortOrder, editorAlias));
|
||||
sortOrder++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user