Merge branch 'temp8' into temp8-umbhelper-vs-umbcontext-cleanup

This commit is contained in:
Stephan
2019-02-15 10:17:14 +01:00
26 changed files with 107 additions and 156 deletions

View File

@@ -42,30 +42,30 @@ namespace Umbraco.Core.Composing
private string _currentAssembliesHash;
private IEnumerable<Assembly> _assemblies;
private bool _reportedChange;
private static LocalTempStorage _localTempStorage;
private static string _localTempPath;
private static string _fileBasePath;
/// <summary>
/// Initializes a new instance of the <see cref="TypeLoader"/> class.
/// </summary>
/// <param name="runtimeCache">The application runtime cache.</param>
/// <param name="localTempStorage">Files storage mode.</param>
/// <param name="localTempPath">Files storage location.</param>
/// <param name="logger">A profiling logger.</param>
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)
{ }
/// <summary>
/// Initializes a new instance of the <see cref="TypeLoader"/> class.
/// </summary>
/// <param name="runtimeCache">The application runtime cache.</param>
/// <param name="localTempStorage">Files storage mode.</param>
/// <param name="localTempPath">Files storage location.</param>
/// <param name="logger">A profiling logger.</param>
/// <param name="detectChanges">Whether to detect changes using hashes.</param>
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);

View File

@@ -11,12 +11,12 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.Strings;
using Umbraco.Core.Sync;
namespace Umbraco.Core.Compose
namespace Umbraco.Core
{
/// <summary>
/// Provides extension methods to the <see cref="Composition"/> class.
/// </summary>
public static class CompositionExtensions
public static partial class CompositionExtensions
{
#region FileSystems

View File

@@ -8,7 +8,7 @@ namespace Umbraco.Core
/// <summary>
/// Provides extension methods to the <see cref="Composition"/> class.
/// </summary>
public static class CompositionExtensions
public static partial class CompositionExtensions
{
#region Essentials

View File

@@ -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
}
}
/// <summary>
/// This is the location type to store temporary files such as cache files or other localized files for a given machine
/// </summary>
/// <remarks>
/// Currently used for the xml cache file and the plugin cache files
/// </remarks>
/// <inheritdoc />
public LocalTempStorage LocalTempStorageLocation
{
get
@@ -295,6 +283,31 @@ namespace Umbraco.Core.Configuration
}
}
/// <inheritdoc />
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");
}
}
}
/// <summary>
/// Gets the default UI language.
/// </summary>
@@ -348,10 +361,5 @@ namespace Umbraco.Core.Configuration
}
}
}
}
}

View File

@@ -1,6 +1,4 @@
using System;
namespace Umbraco.Core.Configuration
namespace Umbraco.Core.Configuration
{
/// <summary>
/// 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; }
/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// Used for some cache files and for specific environments such as Azure
/// </remarks>
LocalTempStorage LocalTempStorageLocation { get; }
/// <summary>
/// Gets the location of temporary files.
/// </summary>
string LocalTempPath { get; }
}
}

View File

@@ -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");
}
}
}

View File

@@ -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<T>()' and NOT '_factory.GetInstance<T>'

View File

@@ -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);

View File

@@ -161,7 +161,7 @@
<Compile Include="Composing\ComponentComposer.cs" />
<Compile Include="Composing\Composers.cs" />
<Compile Include="Composing\Composition.cs" />
<Compile Include="Compose\CompositionExtensions.cs" />
<Compile Include="CompositionExtensions_Accessors.cs" />
<Compile Include="Composing\DisableAttribute.cs" />
<Compile Include="Composing\DisableComposerAttribute.cs" />
<Compile Include="Composing\EnableAttribute.cs" />
@@ -186,7 +186,7 @@
<Compile Include="Composing\CompositionExtensions\FileSystems.cs" />
<Compile Include="Composing\CompositionExtensions\Repositories.cs" />
<Compile Include="Composing\CompositionExtensions\Services.cs" />
<Compile Include="CompositionExtensions.cs" />
<Compile Include="CompositionExtensions_Essentials.cs" />
<Compile Include="FactoryExtensions.cs" />
<Compile Include="Composing\RegisterFactory.cs" />
<Compile Include="Composing\Current.cs" />

View File

@@ -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<ILogger>(), Mock.Of<IProfiler>());
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
};

View File

@@ -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<ILogger>(), Mock.Of<IProfiler>()));
_typeLoader = new TypeLoader(NoAppCache.Instance, IOHelper.MapPath("~/App_Data/TEMP"), new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
foreach (var file in Directory.GetFiles(IOHelper.MapPath(SystemDirectories.TempData.EnsureEndsWith('/') + "TypesCache")))
File.Delete(file);

View File

@@ -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<IFactory>();
var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
container.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns(
new TypeLoader(NoAppCache.Instance, LocalTempStorage.Default, new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
new TypeLoader(NoAppCache.Instance, IOHelper.MapPath("~/App_Data/TEMP"), new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
Current.Factory = container.Object;
Udi.ResetUdiTypes();

View File

@@ -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<IMediaTypeService>());
var profile1 = new ContentTypeMapperProfile(_editorsMock.Object, _dataTypeService.Object, _fileService.Object, _contentTypeService.Object, Mock.Of<IMediaTypeService>(), Mock.Of<ILogger>());
configuration.AddProfile(profile1);
var profile2 = new EntityMapperProfile();
configuration.AddProfile(profile2);

View File

@@ -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<IMapperCollection>(() => factory.GetInstance<IMapperCollection>()));
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<IMainDom>(() => mainDom), new Lazy<IServerRegistrar>(() => factory.GetInstance<IServerRegistrar>()));
@@ -242,7 +242,7 @@ namespace Umbraco.Tests.Runtimes
var profilingLogger = new ProfilingLogger(logger, profiler);
var appCaches = AppCaches.Disabled;
var databaseFactory = Mock.Of<IUmbracoDatabaseFactory>();
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<IRuntimeState>();
Mock.Get(runtimeState).Setup(x => x.Level).Returns(RuntimeLevel.Run);
var mainDom = Mock.Of<IMainDom>();

View File

@@ -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<ILogger>(), Mock.Of<IProfiler>());
var typeLoader = new TypeLoader(NoAppCache.Instance,
LocalTempStorage.Default,
IOHelper.MapPath("~/App_Data/TEMP"),
logger,
false);

View File

@@ -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[]
{

View File

@@ -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<IFactory>();
factory.Setup(x => x.GetInstance(typeof(TypeLoader))).Returns(
new TypeLoader(NoAppCache.Instance, LocalTempStorage.Default, new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
new TypeLoader(NoAppCache.Instance, IOHelper.MapPath("~/App_Data/TEMP"), new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
factory.Setup(x => x.GetInstance(typeof (ServiceContext))).Returns(serviceContext);
var settings = SettingsForTests.GetDefaultUmbracoSettings();

View File

@@ -6,6 +6,7 @@ using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Tests.TestHelpers;
using Umbraco.Web;
@@ -260,7 +261,7 @@ namespace Umbraco.Tests.Web
.Setup(x => x.GetInstance(typeof(TypeLoader)))
.Returns(new TypeLoader(
NoAppCache.Instance,
LocalTempStorage.Default,
IOHelper.MapPath("~/App_Data/TEMP"),
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())
)
);

View File

@@ -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

View File

@@ -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))

View File

@@ -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
/// </summary>
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<DocumentTypeSave, IContentType>()
//do the base mapping
@@ -74,7 +75,7 @@ namespace Umbraco.Web.Models.Mapping
CreateMap<IMemberType, MemberTypeDisplay>()
//map base logic
.MapBaseContentTypeEntityToDisplay<IMemberType, MemberTypeDisplay, MemberPropertyTypeDisplay>(propertyEditors, dataTypeService, contentTypeService)
.MapBaseContentTypeEntityToDisplay<IMemberType, MemberTypeDisplay, MemberPropertyTypeDisplay>(propertyEditors, dataTypeService, contentTypeService, logger)
.AfterMap((memberType, display) =>
{
//map the MemberCanEditProperty,MemberCanViewProperty,IsSensitiveData
@@ -93,7 +94,7 @@ namespace Umbraco.Web.Models.Mapping
CreateMap<IMediaType, MediaTypeDisplay>()
//map base logic
.MapBaseContentTypeEntityToDisplay<IMediaType, MediaTypeDisplay, PropertyTypeDisplay>(propertyEditors, dataTypeService, contentTypeService)
.MapBaseContentTypeEntityToDisplay<IMediaType, MediaTypeDisplay, PropertyTypeDisplay>(propertyEditors, dataTypeService, contentTypeService, logger)
.AfterMap((source, dest) =>
{
//default listview
@@ -109,7 +110,7 @@ namespace Umbraco.Web.Models.Mapping
CreateMap<IContentType, DocumentTypeDisplay>()
//map base logic
.MapBaseContentTypeEntityToDisplay<IContentType, DocumentTypeDisplay, PropertyTypeDisplay>(propertyEditors, dataTypeService, contentTypeService)
.MapBaseContentTypeEntityToDisplay<IContentType, DocumentTypeDisplay, PropertyTypeDisplay>(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())

View File

@@ -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<TSource, TDestination> MapBaseContentTypeEntityToDisplay<TSource, TDestination, TPropertyTypeDisplay>(
this IMappingExpression<TSource, TDestination> mapping, PropertyEditorCollection propertyEditors,
IDataTypeService dataTypeService, IContentTypeService contentTypeService)
IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILogger logger)
where TSource : IContentTypeComposition
where TDestination : ContentTypeCompositionDisplay<TPropertyTypeDisplay>
where TPropertyTypeDisplay : PropertyTypeDisplay, new()
{
var contentTypeUdiResolver = new ContentTypeUdiResolver();
var lockedCompositionsResolver = new LockedCompositionsResolver(contentTypeService);
var propertyTypeGroupResolver = new PropertyTypeGroupResolver<TPropertyTypeDisplay>(propertyEditors, dataTypeService);
var propertyTypeGroupResolver = new PropertyTypeGroupResolver<TPropertyTypeDisplay>(propertyEditors, dataTypeService, logger);
return mapping
.ForMember(dest => dest.Udi, opt => opt.MapFrom(src => contentTypeUdiResolver.Resolve(src)))

View File

@@ -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;
}
/// <summary>
@@ -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<string, object>()
: dataType.Editor.GetConfigurationEditor().ToConfigurationEditor(dataType.Configuration);
mappedProperties.Add(new TPropertyType
{

View File

@@ -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);

View File

@@ -169,9 +169,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)
{

View File

@@ -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