From b9d554908d1eef0afd79ba3706d7a8dbc59361e7 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 4 Feb 2019 21:03:45 +0100 Subject: [PATCH 1/6] Track redirects for invariant content under variant content --- src/Umbraco.Web/Routing/RedirectTrackingComponent.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs index c49dffd6e4..8877ee2884 100644 --- a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs +++ b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs @@ -157,9 +157,14 @@ namespace Umbraco.Web.Routing { var entityContent = contentCache.GetById(entity.Id); if (entityContent == null) continue; + + // get the default affected cultures by going up the tree until we find the first culture variant entity (default to no cultures) + var defaultCultures = entityContent.AncestorsOrSelf()?.FirstOrDefault(a => a.Cultures.Any())?.Cultures.Select(c => c.Key).ToArray() + ?? new[] {(string) null}; foreach (var x in entityContent.DescendantsOrSelf()) { - var cultures = x.Cultures.Any() ? x.Cultures.Select(c => c.Key) : new[] {(string) null}; + // if this entity defines specific cultures, use those instead of the default ones + var cultures = x.Cultures.Any() ? x.Cultures.Select(c => c.Key) : defaultCultures; foreach (var culture in cultures) { From 3223f23ce4c7b0327a29ef513ac7f92714ec31b2 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 15 Feb 2019 14:41:20 +1100 Subject: [PATCH 2/6] Dont throw if a property editor isn't found, this prevents the user from doing anything (i.e. if a DLL is removed for some reason like package uninstall), instead default to label so that the admin can actually make changes. --- .../Mapping/ContentTypeModelMappingTests.cs | 2 +- .../Mapping/ContentTypeMapperProfile.cs | 9 ++++---- .../Mapping/ContentTypeProfileExtensions.cs | 5 +++-- .../Mapping/PropertyTypeGroupResolver.cs | 21 ++++++++++++++----- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs index d869b31798..2e6cfaae89 100644 --- a/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/ContentTypeModelMappingTests.cs @@ -37,7 +37,7 @@ namespace Umbraco.Tests.Models.Mapping Mapper.Initialize(configuration => { //initialize our content type mapper - var profile1 = new ContentTypeMapperProfile(_editorsMock.Object, _dataTypeService.Object, _fileService.Object, _contentTypeService.Object, Mock.Of()); + var profile1 = new ContentTypeMapperProfile(_editorsMock.Object, _dataTypeService.Object, _fileService.Object, _contentTypeService.Object, Mock.Of(), Mock.Of()); configuration.AddProfile(profile1); var profile2 = new EntityMapperProfile(); configuration.AddProfile(profile2); diff --git a/src/Umbraco.Web/Models/Mapping/ContentTypeMapperProfile.cs b/src/Umbraco.Web/Models/Mapping/ContentTypeMapperProfile.cs index ee78c692ff..6653877d24 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentTypeMapperProfile.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentTypeMapperProfile.cs @@ -2,6 +2,7 @@ using System.Linq; using AutoMapper; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Web.Models.ContentEditing; @@ -15,7 +16,7 @@ namespace Umbraco.Web.Models.Mapping /// internal class ContentTypeMapperProfile : Profile { - public ContentTypeMapperProfile(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IFileService fileService, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService) + public ContentTypeMapperProfile(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IFileService fileService, IContentTypeService contentTypeService, IMediaTypeService mediaTypeService, ILogger logger) { CreateMap() //do the base mapping @@ -74,7 +75,7 @@ namespace Umbraco.Web.Models.Mapping CreateMap() //map base logic - .MapBaseContentTypeEntityToDisplay(propertyEditors, dataTypeService, contentTypeService) + .MapBaseContentTypeEntityToDisplay(propertyEditors, dataTypeService, contentTypeService, logger) .AfterMap((memberType, display) => { //map the MemberCanEditProperty,MemberCanViewProperty,IsSensitiveData @@ -93,7 +94,7 @@ namespace Umbraco.Web.Models.Mapping CreateMap() //map base logic - .MapBaseContentTypeEntityToDisplay(propertyEditors, dataTypeService, contentTypeService) + .MapBaseContentTypeEntityToDisplay(propertyEditors, dataTypeService, contentTypeService, logger) .AfterMap((source, dest) => { //default listview @@ -109,7 +110,7 @@ namespace Umbraco.Web.Models.Mapping CreateMap() //map base logic - .MapBaseContentTypeEntityToDisplay(propertyEditors, dataTypeService, contentTypeService) + .MapBaseContentTypeEntityToDisplay(propertyEditors, dataTypeService, contentTypeService, logger) .ForMember(dto => dto.AllowedTemplates, opt => opt.Ignore()) .ForMember(dto => dto.DefaultTemplate, opt => opt.Ignore()) .ForMember(display => display.Notifications, opt => opt.Ignore()) diff --git a/src/Umbraco.Web/Models/Mapping/ContentTypeProfileExtensions.cs b/src/Umbraco.Web/Models/Mapping/ContentTypeProfileExtensions.cs index d05295a546..9ec8e572b3 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentTypeProfileExtensions.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentTypeProfileExtensions.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using AutoMapper; +using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; @@ -119,14 +120,14 @@ namespace Umbraco.Web.Models.Mapping public static IMappingExpression MapBaseContentTypeEntityToDisplay( this IMappingExpression mapping, PropertyEditorCollection propertyEditors, - IDataTypeService dataTypeService, IContentTypeService contentTypeService) + IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILogger logger) where TSource : IContentTypeComposition where TDestination : ContentTypeCompositionDisplay where TPropertyTypeDisplay : PropertyTypeDisplay, new() { var contentTypeUdiResolver = new ContentTypeUdiResolver(); var lockedCompositionsResolver = new LockedCompositionsResolver(contentTypeService); - var propertyTypeGroupResolver = new PropertyTypeGroupResolver(propertyEditors, dataTypeService); + var propertyTypeGroupResolver = new PropertyTypeGroupResolver(propertyEditors, dataTypeService, logger); return mapping .ForMember(dest => dest.Udi, opt => opt.MapFrom(src => contentTypeUdiResolver.Resolve(src))) diff --git a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs index 89d731efa2..bbbf5e2746 100644 --- a/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/PropertyTypeGroupResolver.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using Umbraco.Core; +using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Services; @@ -15,11 +16,13 @@ namespace Umbraco.Web.Models.Mapping { private readonly PropertyEditorCollection _propertyEditors; private readonly IDataTypeService _dataTypeService; + private readonly ILogger _logger; - public PropertyTypeGroupResolver(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService) + public PropertyTypeGroupResolver(PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, ILogger logger) { _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; + _logger = logger; } /// @@ -198,14 +201,22 @@ namespace Umbraco.Web.Models.Mapping foreach (var p in properties.Where(x => x.DataTypeId != 0).OrderBy(x => x.SortOrder)) { - - var propertyEditor = _propertyEditors[p.PropertyEditorAlias]; + var propertyEditorAlias = p.PropertyEditorAlias; + var propertyEditor = _propertyEditors[propertyEditorAlias]; var dataType = _dataTypeService.GetDataType(p.DataTypeId); + //fixme: Don't explode if we can't find this, log an error and change this to a label if (propertyEditor == null) - throw new InvalidOperationException("No property editor could be resolved with the alias: " + p.PropertyEditorAlias + ", ensure all packages are installed correctly."); + { + _logger.Error(GetType(), + "No property editor could be resolved with the alias: {PropertyEditorAlias}, defaulting to label", p.PropertyEditorAlias); + propertyEditorAlias = Constants.PropertyEditors.Aliases.NoEdit; + propertyEditor = _propertyEditors[propertyEditorAlias]; + } - var config = dataType.Editor.GetConfigurationEditor().ToConfigurationEditor(dataType.Configuration); + var config = propertyEditor == null + ? new Dictionary() + : dataType.Editor.GetConfigurationEditor().ToConfigurationEditor(dataType.Configuration); mappedProperties.Add(new TPropertyType { From ed0769f74b15780f7edfdac0783b144f9c2b883c Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 15 Feb 2019 08:51:03 +0100 Subject: [PATCH 3/6] Fix for invariant previews --- .../components/content/edit.controller.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js index 9844118858..03ed7aadaf 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js @@ -818,14 +818,15 @@ previewWindow.location.href = redirect; } else { - var selectedVariant; - if (!$scope.culture) { - selectedVariant = $scope.content.variants[0]; - } - else { - selectedVariant = _.find($scope.content.variants, function (v) { - return v.language.culture === $scope.culture; + var selectedVariant = $scope.content.variants[0]; + if ($scope.culture) { + var found = _.find($scope.content.variants, function (v) { + return (v.language && v.language.culture === $scope.culture); }); + + if(found){ + selectedVariant = found; + } } //ensure the save flag is set From 64154da4e4ab11c74e0f40f87b2fadc8030a7ebc Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 15 Feb 2019 08:46:57 +0100 Subject: [PATCH 4/6] Get LocalTempPath in GlobalSettings --- src/Umbraco.Core/Composing/TypeLoader.cs | 34 ++++---------- .../Configuration/GlobalSettings.cs | 44 +++++++++++-------- .../Configuration/IGlobalSettings.cs | 14 +++--- src/Umbraco.Core/IO/SystemFiles.cs | 22 +--------- src/Umbraco.Core/Runtime/CoreRuntime.cs | 3 +- .../Sync/DatabaseServerMessenger.cs | 22 +--------- .../Composing/ComposingTestBase.cs | 3 +- .../Composing/TypeLoaderTests.cs | 2 +- src/Umbraco.Tests/CoreThings/UdiTests.cs | 3 +- .../FrontEnd/UmbracoHelperTests.cs | 3 +- src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 4 +- .../TestHelpers/BaseUsingSqlCeSyntax.cs | 3 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 2 +- .../Web/TemplateUtilitiesTests.cs | 3 +- .../NuCache/PublishedSnapshotService.cs | 22 +--------- .../Runtime/WebRuntimeComponent.cs | 7 +-- 16 files changed, 61 insertions(+), 130 deletions(-) diff --git a/src/Umbraco.Core/Composing/TypeLoader.cs b/src/Umbraco.Core/Composing/TypeLoader.cs index 08060ca65d..af9277fce9 100644 --- a/src/Umbraco.Core/Composing/TypeLoader.cs +++ b/src/Umbraco.Core/Composing/TypeLoader.cs @@ -42,30 +42,30 @@ namespace Umbraco.Core.Composing private string _currentAssembliesHash; private IEnumerable _assemblies; private bool _reportedChange; - private static LocalTempStorage _localTempStorage; + private static string _localTempPath; private static string _fileBasePath; /// /// Initializes a new instance of the class. /// /// The application runtime cache. - /// Files storage mode. + /// Files storage location. /// A profiling logger. - public TypeLoader(IAppPolicyCache runtimeCache, LocalTempStorage localTempStorage, IProfilingLogger logger) - : this(runtimeCache, localTempStorage, logger, true) + public TypeLoader(IAppPolicyCache runtimeCache, string localTempPath, IProfilingLogger logger) + : this(runtimeCache, localTempPath, logger, true) { } /// /// Initializes a new instance of the class. /// /// The application runtime cache. - /// Files storage mode. + /// Files storage location. /// A profiling logger. /// Whether to detect changes using hashes. - internal TypeLoader(IAppPolicyCache runtimeCache, LocalTempStorage localTempStorage, IProfilingLogger logger, bool detectChanges) + internal TypeLoader(IAppPolicyCache runtimeCache, string localTempPath, IProfilingLogger logger, bool detectChanges) { _runtimeCache = runtimeCache ?? throw new ArgumentNullException(nameof(runtimeCache)); - _localTempStorage = localTempStorage == LocalTempStorage.Unknown ? LocalTempStorage.Default : localTempStorage; + _localTempPath = localTempPath; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); if (detectChanges) @@ -388,25 +388,7 @@ namespace Umbraco.Core.Composing if (_fileBasePath != null) return _fileBasePath; - switch (_localTempStorage) - { - case LocalTempStorage.AspNetTemp: - _fileBasePath = Path.Combine(HttpRuntime.CodegenDir, "UmbracoData", "umbraco-types"); - break; - case LocalTempStorage.EnvironmentTemp: - // include the appdomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back - // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not - // utilizing an old path - assuming we cannot have SHA1 collisions on AppDomainAppId - var appDomainHash = HttpRuntime.AppDomainAppId.ToSHA1(); - var cachePath = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", appDomainHash); - _fileBasePath = Path.Combine(cachePath, "umbraco-types"); - break; - case LocalTempStorage.Default: - default: - var tempFolder = IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "TypesCache"); - _fileBasePath = Path.Combine(tempFolder, "umbraco-types." + NetworkHelper.FileSafeMachineName); - break; - } + _fileBasePath = Path.Combine(_localTempPath, "TypesCache", "umbraco-types." + NetworkHelper.FileSafeMachineName); // ensure that the folder exists var directory = Path.GetDirectoryName(_fileBasePath); diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index 02b26aec86..1fd770607c 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -4,15 +4,8 @@ using System.Linq; using System.Net.Configuration; using System.Web; using System.Web.Configuration; -using System.Web.Hosting; -using System.Web.Security; -using System.Xml; using System.Xml.Linq; -using System.Xml.XPath; -using Umbraco.Core.Composing; using Umbraco.Core.IO; -using Umbraco.Core.Logging; -using Umbraco.Core.Security; namespace Umbraco.Core.Configuration { @@ -277,12 +270,7 @@ namespace Umbraco.Core.Configuration } } - /// - /// This is the location type to store temporary files such as cache files or other localized files for a given machine - /// - /// - /// Currently used for the xml cache file and the plugin cache files - /// + /// public LocalTempStorage LocalTempStorageLocation { get @@ -295,6 +283,31 @@ namespace Umbraco.Core.Configuration } } + /// + public string LocalTempPath + { + get + { + switch (LocalTempStorageLocation) + { + case LocalTempStorage.AspNetTemp: + return System.IO.Path.Combine(HttpRuntime.CodegenDir, "UmbracoData"); + case LocalTempStorage.EnvironmentTemp: + // TODO: why has this to be repeated everywhere?! + // include the appdomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back + // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not + // utilizing an old path - assuming we cannot have SHA1 collisions on AppDomainAppId + var appDomainHash = HttpRuntime.AppDomainAppId.GenerateHash(); + return System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", appDomainHash); + //case LocalTempStorage.Default: + //case LocalTempStorage.Unknown: + default: + return IOHelper.MapPath("~/App_Data/TEMP"); + } + } + } + + /// /// Gets the default UI language. /// @@ -348,10 +361,5 @@ namespace Umbraco.Core.Configuration } } } - } - - - - } diff --git a/src/Umbraco.Core/Configuration/IGlobalSettings.cs b/src/Umbraco.Core/Configuration/IGlobalSettings.cs index b3c8ded1c0..b96434c30c 100644 --- a/src/Umbraco.Core/Configuration/IGlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/IGlobalSettings.cs @@ -1,6 +1,4 @@ -using System; - -namespace Umbraco.Core.Configuration +namespace Umbraco.Core.Configuration { /// /// Contains general settings information for the entire Umbraco instance based on information from web.config appsettings @@ -61,11 +59,13 @@ namespace Umbraco.Core.Configuration int VersionCheckPeriod { get; } /// - /// This is the location type to store temporary files such as cache files or other localized files for a given machine + /// Gets the configuration for the location of temporary files. /// - /// - /// Used for some cache files and for specific environments such as Azure - /// LocalTempStorage LocalTempStorageLocation { get; } + + /// + /// Gets the location of temporary files. + /// + string LocalTempPath { get; } } } diff --git a/src/Umbraco.Core/IO/SystemFiles.cs b/src/Umbraco.Core/IO/SystemFiles.cs index f3376901a9..12e3f57d99 100644 --- a/src/Umbraco.Core/IO/SystemFiles.cs +++ b/src/Umbraco.Core/IO/SystemFiles.cs @@ -1,6 +1,4 @@ -using System; -using System.IO; -using System.Web; +using System.IO; using Umbraco.Core.Configuration; namespace Umbraco.Core.IO @@ -12,23 +10,7 @@ namespace Umbraco.Core.IO // TODO: Kill this off we don't have umbraco.config XML cache we now have NuCache public static string GetContentCacheXml(IGlobalSettings globalSettings) { - switch (globalSettings.LocalTempStorageLocation) - { - case LocalTempStorage.AspNetTemp: - return Path.Combine(HttpRuntime.CodegenDir, @"UmbracoData\umbraco.config"); - case LocalTempStorage.EnvironmentTemp: - var appDomainHash = HttpRuntime.AppDomainAppId.ToSHA1(); - var cachePath = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", - //include the appdomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back - // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not - // utilizing an old path - appDomainHash); - return Path.Combine(cachePath, "umbraco.config"); - case LocalTempStorage.Default: - return IOHelper.ReturnPath(Constants.AppSettings.ContentXML, "~/App_Data/umbraco.config"); - default: - throw new ArgumentOutOfRangeException(); - } + return Path.Combine(globalSettings.LocalTempPath, "umbraco.config"); } } } diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index 813c2e6a18..7462ecdf67 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -112,8 +112,7 @@ namespace Umbraco.Core.Runtime var configs = GetConfigs(); // type loader - var localTempStorage = configs.Global().LocalTempStorageLocation; - var typeLoader = new TypeLoader(appCaches.RuntimeCache, localTempStorage, ProfilingLogger); + var typeLoader = new TypeLoader(appCaches.RuntimeCache, configs.Global().LocalTempPath, ProfilingLogger); // runtime state // beware! must use '() => _factory.GetInstance()' and NOT '_factory.GetInstance' diff --git a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs index 741cc2bab1..7442169b44 100644 --- a/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs +++ b/src/Umbraco.Core/Sync/DatabaseServerMessenger.cs @@ -534,27 +534,7 @@ namespace Umbraco.Core.Sync { var fileName = HttpRuntime.AppDomainAppId.ReplaceNonAlphanumericChars(string.Empty) + "-lastsynced.txt"; - string distCacheFilePath; - switch (globalSettings.LocalTempStorageLocation) - { - case LocalTempStorage.AspNetTemp: - distCacheFilePath = Path.Combine(HttpRuntime.CodegenDir, @"UmbracoData", fileName); - break; - case LocalTempStorage.EnvironmentTemp: - var appDomainHash = HttpRuntime.AppDomainAppId.ToSHA1(); - var cachePath = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", - //include the appdomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back - // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not - // utilizing an old path - appDomainHash); - distCacheFilePath = Path.Combine(cachePath, fileName); - break; - case LocalTempStorage.Default: - default: - var tempFolder = IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "DistCache"); - distCacheFilePath = Path.Combine(tempFolder, fileName); - break; - } + var distCacheFilePath = Path.Combine(globalSettings.LocalTempPath, "DistCache", fileName); //ensure the folder exists var folder = Path.GetDirectoryName(distCacheFilePath); diff --git a/src/Umbraco.Tests/Composing/ComposingTestBase.cs b/src/Umbraco.Tests/Composing/ComposingTestBase.cs index 407d953509..ef364afd38 100644 --- a/src/Umbraco.Tests/Composing/ComposingTestBase.cs +++ b/src/Umbraco.Tests/Composing/ComposingTestBase.cs @@ -5,6 +5,7 @@ using NUnit.Framework; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; +using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Tests.TestHelpers; @@ -21,7 +22,7 @@ namespace Umbraco.Tests.Composing { ProfilingLogger = new ProfilingLogger(Mock.Of(), Mock.Of()); - TypeLoader = new TypeLoader(NoAppCache.Instance, LocalTempStorage.Default, ProfilingLogger, detectChanges: false) + TypeLoader = new TypeLoader(NoAppCache.Instance, IOHelper.MapPath("~/App_Data/TEMP"), ProfilingLogger, detectChanges: false) { AssembliesToScan = AssembliesToScan }; diff --git a/src/Umbraco.Tests/Composing/TypeLoaderTests.cs b/src/Umbraco.Tests/Composing/TypeLoaderTests.cs index 2dbd3055cb..0f92e142f7 100644 --- a/src/Umbraco.Tests/Composing/TypeLoaderTests.cs +++ b/src/Umbraco.Tests/Composing/TypeLoaderTests.cs @@ -27,7 +27,7 @@ namespace Umbraco.Tests.Composing public void Initialize() { // this ensures it's reset - _typeLoader = new TypeLoader(NoAppCache.Instance, LocalTempStorage.Default, new ProfilingLogger(Mock.Of(), Mock.Of())); + _typeLoader = new TypeLoader(NoAppCache.Instance, IOHelper.MapPath("~/App_Data/TEMP"), new ProfilingLogger(Mock.Of(), Mock.Of())); foreach (var file in Directory.GetFiles(IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "TypesCache"))) File.Delete(file); diff --git a/src/Umbraco.Tests/CoreThings/UdiTests.cs b/src/Umbraco.Tests/CoreThings/UdiTests.cs index c700b78c4b..100b39c548 100644 --- a/src/Umbraco.Tests/CoreThings/UdiTests.cs +++ b/src/Umbraco.Tests/CoreThings/UdiTests.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Deploy; +using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Serialization; using Umbraco.Tests.TestHelpers; @@ -26,7 +27,7 @@ namespace Umbraco.Tests.CoreThings var container = new Mock(); var globalSettings = SettingsForTests.GenerateMockGlobalSettings(); container.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns( - new TypeLoader(NoAppCache.Instance, LocalTempStorage.Default, new ProfilingLogger(Mock.Of(), Mock.Of()))); + new TypeLoader(NoAppCache.Instance, IOHelper.MapPath("~/App_Data/TEMP"), new ProfilingLogger(Mock.Of(), Mock.Of()))); Current.Factory = container.Object; Udi.ResetUdiTypes(); diff --git a/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs b/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs index 1c0b407ac6..b7b85cc4de 100644 --- a/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs +++ b/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs @@ -8,6 +8,7 @@ using Umbraco.Tests.TestHelpers; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; +using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Web; @@ -414,7 +415,7 @@ namespace Umbraco.Tests.FrontEnd .Setup(x => x.GetInstance(typeof(TypeLoader))) .Returns(new TypeLoader( NoAppCache.Instance, - LocalTempStorage.Default, + IOHelper.MapPath("~/App_Data/TEMP"), new ProfilingLogger(Mock.Of(), Mock.Of()) ) ); diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index e191d282ca..915199654f 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -60,7 +60,7 @@ namespace Umbraco.Tests.Runtimes var profilingLogger = new ProfilingLogger(logger, profiler); var appCaches = new AppCaches(); // FIXME: has HttpRuntime stuff? var databaseFactory = new UmbracoDatabaseFactory(logger, new Lazy(() => factory.GetInstance())); - var typeLoader = new TypeLoader(appCaches.RuntimeCache, LocalTempStorage.Default, profilingLogger); + var typeLoader = new TypeLoader(appCaches.RuntimeCache, IOHelper.MapPath("~/App_Data/TEMP"), profilingLogger); var mainDom = new SimpleMainDom(); var runtimeState = new RuntimeState(logger, null, null, new Lazy(() => mainDom), new Lazy(() => factory.GetInstance())); @@ -242,7 +242,7 @@ namespace Umbraco.Tests.Runtimes var profilingLogger = new ProfilingLogger(logger, profiler); var appCaches = AppCaches.Disabled; var databaseFactory = Mock.Of(); - var typeLoader = new TypeLoader(appCaches.RuntimeCache, LocalTempStorage.Default, profilingLogger); + var typeLoader = new TypeLoader(appCaches.RuntimeCache, IOHelper.MapPath("~/App_Data/TEMP"), profilingLogger); var runtimeState = Mock.Of(); Mock.Get(runtimeState).Setup(x => x.Level).Returns(RuntimeLevel.Run); var mainDom = Mock.Of(); diff --git a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs index 2e1aadc9bb..ca32e71e5b 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs @@ -8,6 +8,7 @@ using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; +using Umbraco.Core.IO; using Umbraco.Core.Persistence; using Umbraco.Tests.Components; @@ -38,7 +39,7 @@ namespace Umbraco.Tests.TestHelpers var logger = new ProfilingLogger(Mock.Of(), Mock.Of()); var typeLoader = new TypeLoader(NoAppCache.Instance, - LocalTempStorage.Default, + IOHelper.MapPath("~/App_Data/TEMP"), logger, false); diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index dc41c64444..dd9aafa037 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -280,7 +280,7 @@ namespace Umbraco.Tests.Testing // common to all tests = cannot be overriden private static TypeLoader CreateCommonTypeLoader(IAppPolicyCache runtimeCache, IGlobalSettings globalSettings, IProfilingLogger logger) { - return new TypeLoader(runtimeCache, globalSettings.LocalTempStorageLocation, logger, false) + return new TypeLoader(runtimeCache, globalSettings.LocalTempPath, logger, false) { AssembliesToScan = new[] { diff --git a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs index d4945dfc58..8a4e3e515b 100644 --- a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs +++ b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs @@ -19,6 +19,7 @@ using Umbraco.Web.Routing; using Umbraco.Web.Security; using Umbraco.Web.Templates; using Umbraco.Core.Configuration; +using Umbraco.Core.IO; namespace Umbraco.Tests.Web { @@ -39,7 +40,7 @@ namespace Umbraco.Tests.Web // FIXME: bad in a unit test - but Udi has a static ctor that wants it?! var factory = new Mock(); factory.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns( - new TypeLoader(NoAppCache.Instance, LocalTempStorage.Default, new ProfilingLogger(Mock.Of(), Mock.Of()))); + new TypeLoader(NoAppCache.Instance, IOHelper.MapPath("~/App_Data/TEMP"), new ProfilingLogger(Mock.Of(), Mock.Of()))); factory.Setup(x => x.GetInstance(typeof (ServiceContext))).Returns(serviceContext); var settings = SettingsForTests.GetDefaultUmbracoSettings(); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index 023b8c999a..a85e75f14c 100755 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -276,27 +276,7 @@ namespace Umbraco.Web.PublishedCache.NuCache private string GetLocalFilesPath() { - string path; - var tempLocation = _globalSettings.LocalTempStorageLocation; - switch (tempLocation) - { - case LocalTempStorage.AspNetTemp: - path = Path.Combine(HttpRuntime.CodegenDir, "UmbracoData", "NuCache"); - break; - case LocalTempStorage.EnvironmentTemp: - // TODO: why has this to be repeated everywhere?! - // include the appdomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back - // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not - // utilizing an old path - assuming we cannot have SHA1 collisions on AppDomainAppId - var appDomainHash = HttpRuntime.AppDomainAppId.GenerateHash(); - path = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", appDomainHash, "NuCache"); - break; - //case LocalTempStorage.Default: - //case LocalTempStorage.Unknown: - default: - path = IOHelper.MapPath("~/App_Data/TEMP/NuCache"); - break; - } + var path = Path.Combine(_globalSettings.LocalTempPath, "NuCache"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs index 56e48fea71..b4f947bb5d 100644 --- a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs +++ b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs @@ -234,12 +234,7 @@ namespace Umbraco.Web.Runtime // location to be there if (globalSettings.LocalTempStorageLocation == LocalTempStorage.EnvironmentTemp) { - var appDomainHash = HttpRuntime.AppDomainAppId.ToSHA1(); - var cachePath = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", - //include the AppDomain hash is just a safety check, for example if a website is moved from worker A to worker B and then back - // to worker A again, in theory the %temp% folder should already be empty but we really want to make sure that its not - // utilizing an old path - appDomainHash); + var cachePath = globalSettings.LocalTempPath; //set the file map and composite file default location to the %temp% location BaseCompositeFileProcessingProvider.CompositeFilePathDefaultFolder From 47ee3bf3e4774f282f45e55ec2442ea0e5b3e049 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 15 Feb 2019 09:47:35 +0100 Subject: [PATCH 5/6] Move things around --- ...sitionExtensions.cs => CompositionExtensions_Accessors.cs} | 4 ++-- ...itionExtensions.cs => CompositionExtensions_Essentials.cs} | 2 +- src/Umbraco.Core/Umbraco.Core.csproj | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/Umbraco.Core/{Compose/CompositionExtensions.cs => CompositionExtensions_Accessors.cs} (99%) rename src/Umbraco.Core/{CompositionExtensions.cs => CompositionExtensions_Essentials.cs} (97%) diff --git a/src/Umbraco.Core/Compose/CompositionExtensions.cs b/src/Umbraco.Core/CompositionExtensions_Accessors.cs similarity index 99% rename from src/Umbraco.Core/Compose/CompositionExtensions.cs rename to src/Umbraco.Core/CompositionExtensions_Accessors.cs index 4767797dc1..f19437809e 100644 --- a/src/Umbraco.Core/Compose/CompositionExtensions.cs +++ b/src/Umbraco.Core/CompositionExtensions_Accessors.cs @@ -11,12 +11,12 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.Strings; using Umbraco.Core.Sync; -namespace Umbraco.Core.Compose +namespace Umbraco.Core { /// /// Provides extension methods to the class. /// - public static class CompositionExtensions + public static partial class CompositionExtensions { #region FileSystems diff --git a/src/Umbraco.Core/CompositionExtensions.cs b/src/Umbraco.Core/CompositionExtensions_Essentials.cs similarity index 97% rename from src/Umbraco.Core/CompositionExtensions.cs rename to src/Umbraco.Core/CompositionExtensions_Essentials.cs index 46e8111237..46575c1428 100644 --- a/src/Umbraco.Core/CompositionExtensions.cs +++ b/src/Umbraco.Core/CompositionExtensions_Essentials.cs @@ -8,7 +8,7 @@ namespace Umbraco.Core /// /// Provides extension methods to the class. /// - public static class CompositionExtensions + public static partial class CompositionExtensions { #region Essentials diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index bd3d64254d..29bc0ef62d 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -161,7 +161,7 @@ - + @@ -186,7 +186,7 @@ - + From eab1e46a4b2b144970f7d2ae76385f0071b4ebed Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Fri, 15 Feb 2019 09:58:54 +0100 Subject: [PATCH 6/6] Bugfix in view after UmbracoContext refactoring --- src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml b/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml index 04123128c9..b7e293eed8 100644 --- a/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml +++ b/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml @@ -1,4 +1,5 @@ @model dynamic +@using Umbraco.Web.Composing @using Umbraco.Web.Templates -@Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString(), UmbracoContext.Current.UrlProvider)) +@Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString(), Current.UmbracoContext.UrlProvider))