Merge branch 'netcore/dev' into netcore/feature/untangle-membership

# Conflicts:
#	src/Umbraco.Web/Runtime/WebInitialComposer.cs
This commit is contained in:
Bjarke Berg
2020-03-02 13:19:38 +01:00
118 changed files with 726 additions and 517 deletions

View File

@@ -53,7 +53,7 @@ namespace Umbraco.Web.Cache
{
macroRepoCache.Result.Clear(RepositoryCacheKeys.GetKey<IMacro>(payload.Id));
}
};
}
base.Refresh(json);
}

View File

@@ -126,7 +126,7 @@ namespace Umbraco.Core.Collections
if (_items.TryGetValue(key, out value))
yield return value;
else if (throwOnMissing)
throw new Exception(MissingDependencyError);
throw new Exception($"{MissingDependencyError} Error in type {typeof(TItem).Name}, with key {key}");
}
}
}

View File

@@ -79,9 +79,12 @@ namespace Umbraco.Core.Composing
foreach (var type in types)
EnsureType(type, "register");
// register them
// register them - ensuring that each item is registered with the same lifetime as the collection.
// NOTE: Previously each one was not registered with the same lifetime which would mean that if there
// was a dependency on an individual item, it would resolve a brand new transient instance which isn't what
// we would expect to happen. The same item should be resolved from the container as the collection.
foreach (var type in types)
register.Register(type);
register.Register(type, CollectionLifetime);
_registeredTypes = types;
}

View File

@@ -0,0 +1,7 @@
namespace Umbraco.Core.Configuration
{
public interface IMachineKeyConfig
{
bool HasMachineKey { get;}
}
}

View File

@@ -0,0 +1,29 @@
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(10)]
public class ContentDashboard : IDashboard
{
public string Alias => "contentIntro";
public string[] Sections => new [] { "content" };
public string View => "views/dashboard/default/startupdashboardintro.html";
public IAccessRule[] AccessRules
{
get
{
var rules = new IAccessRule[]
{
new AccessRule {Type = AccessRuleType.Deny, Value = Constants.Security.TranslatorGroupAlias},
new AccessRule {Type = AccessRuleType.Grant, Value = Constants.Security.AdminGroupAlias}
};
return rules;
}
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(20)]
public class ExamineDashboard : IDashboard
{
public string Alias => "settingsExamine";
public string[] Sections => new [] { "settings" };
public string View => "views/dashboard/settings/examinemanagement.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,19 @@
using System;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(10)]
public class FormsDashboard : IDashboard
{
public string Alias => "formsInstall";
public string[] Sections => new [] { Constants.Applications.Forms };
public string View => "views/dashboard/forms/formsdashboardintro.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,20 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(50)]
public class HealthCheckDashboard : IDashboard
{
public string Alias => "settingsHealthCheck";
public string[] Sections => new [] { "settings" };
public string View => "views/dashboard/settings/healthcheck.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(10)]
public class MediaDashboard : IDashboard
{
public string Alias => "mediaFolderBrowser";
public string[] Sections => new [] { "media" };
public string View => "views/dashboard/media/mediafolderbrowser.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(10)]
public class MembersDashboard : IDashboard
{
public string Alias => "memberIntro";
public string[] Sections => new [] { "member" };
public string View => "views/dashboard/members/membersdashboardvideos.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(60)]
public class ProfilerDashboardDashboard : IDashboard
{
public string Alias => "settingsProfiler";
public string[] Sections => new [] { "settings" };
public string View => "views/dashboard/settings/profiler.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,20 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(30)]
public class PublishedStatusDashboard : IDashboard
{
public string Alias => "settingsPublishedStatus";
public string[] Sections => new [] { "settings" };
public string View => "views/dashboard/settings/publishedstatus.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(20)]
public class RedirectUrlDashboard : IDashboard
{
public string Alias => "contentRedirectManager";
public string[] Sections => new [] { "content" };
public string View => "views/dashboard/content/redirecturls.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -0,0 +1,18 @@
using System;
using Umbraco.Core.Composing;
using Umbraco.Core.Dashboards;
namespace Umbraco.Web.Dashboards
{
[Weight(10)]
public class SettingsDashboard : IDashboard
{
public string Alias => "settingsWelcome";
public string[] Sections => new [] { "settings" };
public string View => "views/dashboard/settings/settingsdashboardintro.html";
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
}
}

View File

@@ -41,7 +41,7 @@ namespace Umbraco.Core
public void AddDateTime(DateTime d)
{
_writer.Write(d.Ticks);;
_writer.Write(d.Ticks);
}
public void AddString(string s)

View File

@@ -22,11 +22,6 @@ namespace Umbraco.Core.Hosting
string MapPath(string path);
string ToAbsolute(string virtualPath, string root);
/// <summary>
/// Terminates the current application. The application restarts the next time a request is received for it.
/// </summary>
void LazyRestartApplication();
void RegisterObject(IRegisteredObject registeredObject);
void UnregisterObject(IRegisteredObject registeredObject);
}

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using Umbraco.Core.Hosting;
using Umbraco.Core.Logging;
using Umbraco.Net;
namespace Umbraco.Core.Manifest
{
@@ -13,13 +14,13 @@ namespace Umbraco.Core.Manifest
private static volatile bool _isRestarting;
private readonly ILogger _logger;
private readonly IHostingEnvironment _hostingEnvironment;
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
private readonly List<FileSystemWatcher> _fws = new List<FileSystemWatcher>();
public ManifestWatcher(ILogger logger, IHostingEnvironment hostingEnvironment)
public ManifestWatcher(ILogger logger, IUmbracoApplicationLifetime umbracoApplicationLifetime)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_hostingEnvironment = hostingEnvironment;
_umbracoApplicationLifetime = umbracoApplicationLifetime;
}
public void Start(params string[] packageFolders)
@@ -57,7 +58,7 @@ namespace Umbraco.Core.Manifest
_isRestarting = true;
_logger.Info<ManifestWatcher>("Manifest has changed, app pool is restarting ({Path})", e.FullPath);
_hostingEnvironment.LazyRestartApplication();
_umbracoApplicationLifetime.Restart();
Dispose(); // uh? if the app restarts then this should be disposed anyways?
}
}

View File

@@ -6,7 +6,7 @@ namespace Umbraco.Web.Models
/// <summary>
/// The model used when rendering Partial View Macros
/// </summary>
public class PartialViewMacroModel
public class PartialViewMacroModel : IContentModel
{
public PartialViewMacroModel(IPublishedContent page,

View File

@@ -0,0 +1,14 @@
namespace Umbraco.Net
{
public interface IUmbracoApplicationLifetime
{
/// <summary>
/// A value indicating whether the application is restarting after the current request.
/// </summary>
bool IsRestarting { get; }
/// <summary>
/// Terminates the current application. The application restarts the next time a request is received for it.
/// </summary>
void Restart();
}
}

View File

@@ -0,0 +1,7 @@
namespace Umbraco.Net
{
public interface IUserAgentProvider
{
string GetUserAgent();
}
}

View File

@@ -7,7 +7,7 @@ using Umbraco.Core.Services;
namespace Umbraco.Core.Packaging
{
public class ConflictingPackageData
public class ConflictingPackageData
{
private readonly IMacroService _macroService;
private readonly IFileService _fileService;
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Packaging
return stylesheetNodes
.Select(n =>
{
var xElement = n.Element("Name") ?? n.Element("name"); ;
var xElement = n.Element("Name") ?? n.Element("name");
if (xElement == null)
throw new FormatException("Missing \"Name\" element");

View File

@@ -19,7 +19,7 @@ namespace Umbraco.Core.Models.Packaging
/// <remarks>
/// This is used only for conversions and will not 'get' a PackageDefinition from the repository with a valid ID
/// </remarks>
internal static PackageDefinition FromCompiledPackage(CompiledPackage compiled)
public static PackageDefinition FromCompiledPackage(CompiledPackage compiled)
{
return new PackageDefinition
{

View File

@@ -90,7 +90,7 @@ namespace Umbraco.Core.Packaging
{
var packagesXml = EnsureStorage(out _);
if (packagesXml?.Root == null)
yield break;;
yield break;
foreach (var packageXml in packagesXml.Root.Elements("package"))
yield return _parser.ToPackageDefinition(packageXml);
@@ -518,7 +518,6 @@ namespace Umbraco.Core.Packaging
private XElement GetStylesheetXml(string name, bool includeProperties)
{
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(name));
;
var sts = _fileService.GetStylesheetByName(name);
if (sts == null) return null;
var stylesheetXml = new XElement("Stylesheet");

View File

@@ -51,7 +51,10 @@ namespace Umbraco.Core.Services
IEnumerable<TItem> GetComposedOf(int id); // composition axis
IEnumerable<TItem> GetChildren(int id);
IEnumerable<TItem> GetChildren(Guid id);
bool HasChildren(int id);
bool HasChildren(Guid id);
void Save(TItem item, int userId = Constants.Security.SuperUserId);
void Save(IEnumerable<TItem> items, int userId = Constants.Security.SuperUserId);

View File

@@ -0,0 +1,19 @@
using System;
using Umbraco.Web;
namespace Umbraco.Core
{
public static class UmbracoContextAccessorExtensions
{
public static IUmbracoContext GetRequiredUmbracoContext(this IUmbracoContextAccessor umbracoContextAccessor)
{
if (umbracoContextAccessor == null) throw new ArgumentNullException(nameof(umbracoContextAccessor));
var umbracoContext = umbracoContextAccessor.UmbracoContext;
if(umbracoContext is null) throw new InvalidOperationException("UmbracoContext is null");
return umbracoContext;
}
}
}

View File

@@ -336,7 +336,7 @@ namespace Umbraco.Core.Xml
var child = parent.SelectSingleNode(name);
if (child != null)
{
child.InnerXml = "<![CDATA[" + value + "]]>"; ;
child.InnerXml = "<![CDATA[" + value + "]]>";
return child;
}
return AddCDataNode(xd, name, value);