From c66d49dbfe7eec1433a56eb6a9640a0e6b056a7c Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 28 Oct 2013 01:00:29 +0100 Subject: [PATCH 1/3] PublishedContent - remove useles code in model factory --- .../Models/PublishedContent/PublishedContentModelFactoryImpl.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactoryImpl.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactoryImpl.cs index af2bdd6859..7bc0343add 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactoryImpl.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentModelFactoryImpl.cs @@ -22,8 +22,6 @@ namespace Umbraco.Core.Models.PublishedContent foreach (var type in types) { - if (type.Inherits() == false) - throw new InvalidOperationException(string.Format("Type {0} is marked with PublishedContentModel attribute but does not inherit from PublishedContentExtended.", type.FullName)); var constructor = type.GetConstructor(ctorArgTypes); if (constructor == null) throw new InvalidOperationException(string.Format("Type {0} is missing a public constructor with one argument of type IPublishedContent.", type.FullName)); From 73b7729b82e5819395f4812cab65ac32aac09aac Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 28 Oct 2013 01:01:20 +0100 Subject: [PATCH 2/3] Standalone - fix so it works again --- .../Standalone/StandaloneApplication.cs | 26 ++++++++++++++++++- .../Standalone/StandaloneBootManager.cs | 2 +- .../Standalone/StandaloneHttpContext.cs | 5 +++- src/Umbraco.Web/UmbracoContext.cs | 12 ++++++--- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web/Standalone/StandaloneApplication.cs b/src/Umbraco.Web/Standalone/StandaloneApplication.cs index cdaf8718c1..64e2975dc2 100644 --- a/src/Umbraco.Web/Standalone/StandaloneApplication.cs +++ b/src/Umbraco.Web/Standalone/StandaloneApplication.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Umbraco.Core; +using Umbraco.Core.ObjectResolution; namespace Umbraco.Web.Standalone { @@ -49,17 +50,40 @@ namespace Umbraco.Web.Standalone /// /// Starts the application. /// - public void Start() + public void Start(bool noerr = false) { lock (AppLock) { if (_started) + { + if (noerr) return; throw new InvalidOperationException("Application has already started."); + } Application_Start(this, EventArgs.Empty); _started = true; } } + public void Terminate(bool noerr = false) + { + lock (AppLock) + { + if (_started == false) + { + if (noerr) return; + throw new InvalidOperationException("Application has already been terminated."); + } + + ApplicationContext.Current.DisposeIfDisposable(); // should reset resolution, clear caches & resolvers... + ApplicationContext.Current = null; + UmbracoContext.Current.DisposeIfDisposable(); // dunno + UmbracoContext.Current = null; + + _started = false; + _application = null; + } + } + #endregion #region IApplicationEventHandler management diff --git a/src/Umbraco.Web/Standalone/StandaloneBootManager.cs b/src/Umbraco.Web/Standalone/StandaloneBootManager.cs index 8e69797a4d..b97c06ca68 100644 --- a/src/Umbraco.Web/Standalone/StandaloneBootManager.cs +++ b/src/Umbraco.Web/Standalone/StandaloneBootManager.cs @@ -80,7 +80,7 @@ namespace Umbraco.Web.Standalone base.FreezeResolution(); var httpContext = new StandaloneHttpContext(); - UmbracoContext.EnsureContext(httpContext, ApplicationContext.Current); + UmbracoContext.EnsureContext(httpContext, ApplicationContext.Current, false, false); } } } diff --git a/src/Umbraco.Web/Standalone/StandaloneHttpContext.cs b/src/Umbraco.Web/Standalone/StandaloneHttpContext.cs index ac34e405e5..dec95dd372 100644 --- a/src/Umbraco.Web/Standalone/StandaloneHttpContext.cs +++ b/src/Umbraco.Web/Standalone/StandaloneHttpContext.cs @@ -65,6 +65,9 @@ namespace Umbraco.Web.Standalone internal class StandaloneHttpRequest : HttpRequestBase { - + public override Uri Url + { + get { return new Uri("http://localhost"); } + } } } diff --git a/src/Umbraco.Web/UmbracoContext.cs b/src/Umbraco.Web/UmbracoContext.cs index bffbf76930..47c55de9e0 100644 --- a/src/Umbraco.Web/UmbracoContext.cs +++ b/src/Umbraco.Web/UmbracoContext.cs @@ -54,7 +54,12 @@ namespace Umbraco.Web /// public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext) { - return EnsureContext(httpContext, applicationContext, false); + return EnsureContext(httpContext, applicationContext, false, null); + } + + public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext) + { + return EnsureContext(httpContext, applicationContext, replaceContext, null); } /// @@ -77,7 +82,7 @@ namespace Umbraco.Web /// during the startup process as well. /// See: http://issues.umbraco.org/issue/U4-1890, http://issues.umbraco.org/issue/U4-1717 /// - public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext) + public static UmbracoContext EnsureContext(HttpContextBase httpContext, ApplicationContext applicationContext, bool replaceContext, bool? preview) { if (UmbracoContext.Current != null) { @@ -89,7 +94,8 @@ namespace Umbraco.Web var umbracoContext = new UmbracoContext( httpContext, applicationContext, - PublishedCachesResolver.Current.Caches); + PublishedCachesResolver.Current.Caches, + preview); // create the nice urls provider // there's one per request because there are some behavior parameters that can be changed From 6cfb864055d3f6222d550fb3474fd86bb906e919 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 28 Oct 2013 11:23:09 +1100 Subject: [PATCH 3/3] Fixes DataTypeDefinitionRepository to properly delete a data type including it's pre-values --- .../Persistence/Repositories/DataTypeDefinitionRepository.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs index 7abcc8e4b0..7cd7069751 100644 --- a/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/DataTypeDefinitionRepository.cs @@ -204,6 +204,9 @@ namespace Umbraco.Core.Persistence.Repositories Database.Delete("WHERE id = @Id", new { Id = dto.Id }); } + //Delete the pre-values + Database.Delete("WHERE datatypeNodeId = @Id", new {Id = entity.Id}); + //Delete Content specific data Database.Delete("WHERE nodeId = @Id", new { Id = entity.Id });