From a6093f41bd2b5b490dd497f56203200ee374f181 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 28 Jan 2016 18:02:22 +0100 Subject: [PATCH] Fixes installer login for user and adds notes --- src/Umbraco.Core/Services/ContentService.cs | 7 ++++++ .../Services/ContentTypeService.cs | 7 ++++++ .../InstallSteps/SetUmbracoVersionStep.cs | 25 +++++++++++-------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index 2edc32f367..7c34709787 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -1227,6 +1227,13 @@ namespace Umbraco.Core.Services /// Optional Id of the user issueing the delete operation public void DeleteContentOfType(int contentTypeId, int userId = 0) { + //TODO: This currently this is called from the ContentTypeService but that needs to change, + // if we are deleting a content type, we should just delete the data and do this operation slightly differently. + // This method will recursively go lookup every content item, check if any of it's descendants are + // of a different type, move them to the recycle bin, then permanently delete the content items. + // The main problem with this is that for every content item being deleted, events are raised... + // which we need for many things like keeping caches in sync, but we can surely do this MUCH better. + using (new WriteLock(Locker)) { using (var uow = UowProvider.GetUnitOfWork()) diff --git a/src/Umbraco.Core/Services/ContentTypeService.cs b/src/Umbraco.Core/Services/ContentTypeService.cs index e6ead68810..1401659bf3 100644 --- a/src/Umbraco.Core/Services/ContentTypeService.cs +++ b/src/Umbraco.Core/Services/ContentTypeService.cs @@ -452,6 +452,13 @@ namespace Umbraco.Core.Services using (new WriteLock(Locker)) { + + //TODO: This needs to change, if we are deleting a content type, we should just delete the data, + // this method will recursively go lookup every content item, check if any of it's descendants are + // of a different type, move them to the recycle bin, then permanently delete the content items. + // The main problem with this is that for every content item being deleted, events are raised... + // which we need for many things like keeping caches in sync, but we can surely do this MUCH better. + _contentService.DeleteContentOfType(contentType.Id); var uow = UowProvider.GetUnitOfWork(); diff --git a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs index f7c9b3d6a5..78fe6d3766 100644 --- a/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/SetUmbracoVersionStep.cs @@ -27,6 +27,20 @@ namespace Umbraco.Web.Install.InstallSteps public override InstallSetupResult Execute(object model) { + var ih = new InstallHelper(UmbracoContext.Current); + + //During a new install we'll log the default user in (which is id = 0). + // During an upgrade, the user will already need to be logged in in order to run the installer. + + var security = new WebSecurity(_httpContext, _applicationContext); + //we do this check here because for upgrades the user will already be logged in, for brand new installs, + // they will not be logged in, however we cannot check the current installation status because it will tell + // us that it is in 'upgrade' because we already have a database conn configured and a database. + if (security.IsAuthenticated() == false && GlobalSettings.ConfigurationStatus.IsNullOrWhiteSpace()) + { + security.PerformLogin(0); + } + //This is synonymous with library.RefreshContent() - but we don't want to use library // for anything anymore so welll use the method that it is wrapping. This will just make sure // the correct xml structure exists in the xml cache file. This is required by some upgrade scripts @@ -39,17 +53,8 @@ namespace Umbraco.Web.Install.InstallSteps // Update ClientDependency version var clientDependencyConfig = new ClientDependencyConfiguration(_applicationContext.ProfilingLogger.Logger); var clientDependencyUpdated = clientDependencyConfig.IncreaseVersionNumber(); - - //During a new install we'll log the default user in (which is id = 0). - // During an upgrade, the user will already need to be logged in in order to run the installer. - if (InstallTypeTarget == InstallationType.NewInstall) - { - var security = new WebSecurity(_httpContext, _applicationContext); - security.PerformLogin(0); - } - //reports the ended install - var ih = new InstallHelper(UmbracoContext.Current); + //reports the ended install ih.InstallStatus(true, ""); return null;