From 753fe411c5b96859b381e57d76f31b9fd51a337b Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Tue, 7 May 2013 13:01:18 -0200 Subject: [PATCH] Fixes U4-2090 Content not published after installing starterkit on fresh site (Umbraco 6.1 beta) --- src/Umbraco.Core/Services/PackagingService.cs | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs index 7792a531bf..364d38bd9c 100644 --- a/src/Umbraco.Core/Services/PackagingService.cs +++ b/src/Umbraco.Core/Services/PackagingService.cs @@ -65,10 +65,17 @@ namespace Umbraco.Core.Services select doc; var contents = ParseDocumentRootXml(roots, parentId); - if(contents.Any()) - _contentService.Save(contents, userId); + var importContent = contents as IContent[] ?? contents.ToArray(); + if (importContent.Any()) + { + _contentService.Save(importContent, userId); - return contents; + //Don't just save, also publish + foreach (var content in importContent) + _contentService.Publish(content, userId); + } + + return importContent; } var attribute = element.Attribute("isDoc"); @@ -77,10 +84,18 @@ namespace Umbraco.Core.Services //This is a single doc import var elements = new List { element }; var contents = ParseDocumentRootXml(elements, parentId); - if (contents.Any()) - _contentService.Save(contents, userId); + var importContent = contents as IContent[] ?? contents.ToArray(); + + if (importContent.Any()) + { + _contentService.Save(importContent, userId); - return contents; + //Don't just save, also publish + foreach (var content in importContent) + _contentService.Publish(content, userId); + } + + return importContent; } throw new ArgumentException( @@ -221,7 +236,7 @@ namespace Umbraco.Core.Services _importedContentTypes = new Dictionary(); var documentTypes = name.Equals("DocumentTypes") ? (from doc in element.Elements("DocumentType") select doc).ToList() - : new List {element}; + : new List { element }; //NOTE it might be an idea to sort the doctype XElements based on dependencies //before creating the doc types - should also allow for a better structure/inheritance support. foreach (var documentType in documentTypes) @@ -357,7 +372,7 @@ namespace Umbraco.Core.Services private void UpdateContentTypesTabs(IContentType contentType, XElement tabElement) { - if(tabElement == null) + if (tabElement == null) return; var tabs = tabElement.Elements("Tab"); @@ -391,10 +406,10 @@ namespace Umbraco.Core.Services dataTypeDefinition = dataTypeDefinitions.First(); } } - + // For backwards compatibility, if no datatype with that ID can be found, we're letting this fail silently. // This means that the property will not be created. - if(dataTypeDefinition == null) + if (dataTypeDefinition == null) { LogHelper.Warn(string.Format("Packager: Error handling creation of PropertyType '{0}'. Could not find DataTypeDefintion with unique id '{1}' nor one referencing the DataType with control id '{2}'. Did the package creator forget to package up custom datatypes?", property.Element("Name").Value, dataTypeDefinitionId, dataTypeId)); @@ -403,7 +418,7 @@ namespace Umbraco.Core.Services var propertyType = new PropertyType(dataTypeDefinition) { - Alias = property.Element("Alias").Value, + Alias = property.Element("Alias").Value, Name = property.Element("Name").Value, Description = property.Element("Description").Value, Mandatory = property.Element("Mandatory").Value.ToLowerInvariant().Equals("true"), @@ -499,7 +514,7 @@ namespace Umbraco.Core.Services var dataTypes = new Dictionary(); var dataTypeElements = name.Equals("DataTypes") ? (from doc in element.Elements("DataType") select doc).ToList() - : new List {element.Element("DataType")}; + : new List { element.Element("DataType") }; foreach (var dataTypeElement in dataTypeElements) { @@ -641,13 +656,13 @@ namespace Umbraco.Core.Services { template.MasterTemplateAlias = masterElement.Value; var masterTemplate = templates.FirstOrDefault(x => x.Alias == masterElement.Value); - if(masterTemplate != null) + if (masterTemplate != null) template.MasterTemplateId = new Lazy(() => masterTemplate.Id); } templates.Add(template); } - if(templates.Any()) + if (templates.Any()) _fileService.SaveTemplate(templates, userId); return templates;