diff --git a/src/Umbraco.Abstractions/Configuration/ConfigsExtensions.cs b/src/Umbraco.Abstractions/Configuration/ConfigsExtensions.cs index 275606e8bb..c955cc4796 100644 --- a/src/Umbraco.Abstractions/Configuration/ConfigsExtensions.cs +++ b/src/Umbraco.Abstractions/Configuration/ConfigsExtensions.cs @@ -15,9 +15,9 @@ namespace Umbraco.Core public static class ConfigsExtensions { - public static void AddCoreConfigs(this Configs configs, IIOHelper ioHelper, ISystemDirectories systemDirectories) + public static void AddCoreConfigs(this Configs configs, IIOHelper ioHelper) { - var configDir = new DirectoryInfo(ioHelper.MapPath(systemDirectories.Config)); + var configDir = new DirectoryInfo(ioHelper.MapPath(Constants.SystemDirectories.Config)); // GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition configs.Add(factory => new GridConfig( diff --git a/src/Umbraco.Abstractions/Configuration/GlobalSettingsExtensions.cs b/src/Umbraco.Abstractions/Configuration/GlobalSettingsExtensions.cs index 6f07c474b5..4d8039dfbb 100644 --- a/src/Umbraco.Abstractions/Configuration/GlobalSettingsExtensions.cs +++ b/src/Umbraco.Abstractions/Configuration/GlobalSettingsExtensions.cs @@ -19,16 +19,16 @@ namespace Umbraco.Core.Configuration /// We also make sure that the virtual directory (SystemDirectories.Root) is stripped off first, otherwise we'd end up with something /// like "MyVirtualDirectory-Umbraco" instead of just "Umbraco". /// - public static string GetUmbracoMvcArea(this IGlobalSettings globalSettings, ISystemDirectories systemDirectories) + public static string GetUmbracoMvcArea(this IGlobalSettings globalSettings, IIOHelper ioHelper) { if (_mvcArea != null) return _mvcArea; - _mvcArea = GetUmbracoMvcAreaNoCache(globalSettings, systemDirectories); + _mvcArea = GetUmbracoMvcAreaNoCache(globalSettings, ioHelper); return _mvcArea; } - internal static string GetUmbracoMvcAreaNoCache(this IGlobalSettings globalSettings, ISystemDirectories systemDirectories) + internal static string GetUmbracoMvcAreaNoCache(this IGlobalSettings globalSettings, IIOHelper ioHelper) { if (globalSettings.Path.IsNullOrWhiteSpace()) { @@ -36,8 +36,8 @@ namespace Umbraco.Core.Configuration } var path = globalSettings.Path; - if (path.StartsWith(systemDirectories.Root)) // beware of TrimStart, see U4-2518 - path = path.Substring(systemDirectories.Root.Length); + if (path.StartsWith(ioHelper.Root)) // beware of TrimStart, see U4-2518 + path = path.Substring(ioHelper.Root.Length); return path.TrimStart('~').TrimStart('/').Replace('/', '-').Trim().ToLower(); } diff --git a/src/Umbraco.Abstractions/IO/IIOHelper.cs b/src/Umbraco.Abstractions/IO/IIOHelper.cs index 80e06b0062..3266426cc5 100644 --- a/src/Umbraco.Abstractions/IO/IIOHelper.cs +++ b/src/Umbraco.Abstractions/IO/IIOHelper.cs @@ -18,8 +18,7 @@ namespace Umbraco.Core.IO Attempt TryResolveUrl(string virtualPath); string MapPath(string path, bool useHttpContext); string MapPath(string path); - string ReturnPath(string settingsKey, string standardPath, bool useTilde); - string ReturnPath(string settingsKey, string standardPath); + /// /// Verifies that the current filepath matches a directory where the user is allowed to edit a file. diff --git a/src/Umbraco.Core/Configuration/ConfigsFactory.cs b/src/Umbraco.Core/Configuration/ConfigsFactory.cs index 1a0cb8d7c5..89a31ce10b 100644 --- a/src/Umbraco.Core/Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Core/Configuration/ConfigsFactory.cs @@ -8,22 +8,20 @@ namespace Umbraco.Core.Configuration public class ConfigsFactory : IConfigsFactory { private readonly IIOHelper _ioHelper; - private readonly ISystemDirectories _systemDirectories; - public ConfigsFactory(IIOHelper ioHelper, ISystemDirectories systemDirectories) + public ConfigsFactory(IIOHelper ioHelper) { _ioHelper = ioHelper; - _systemDirectories = systemDirectories; } public Configs Create() { var configs = new Configs(section => ConfigurationManager.GetSection(section)); - configs.Add(() => new GlobalSettings(_ioHelper, _systemDirectories)); + configs.Add(() => new GlobalSettings(_ioHelper)); configs.Add("umbracoConfiguration/settings"); configs.Add("umbracoConfiguration/HealthChecks"); configs.Add(() => new CoreDebug()); - configs.AddCoreConfigs(_ioHelper, _systemDirectories); + configs.AddCoreConfigs(_ioHelper); return configs; } } diff --git a/src/Umbraco.Core/Configuration/GlobalSettings.cs b/src/Umbraco.Core/Configuration/GlobalSettings.cs index ee64cc3842..76d6c2e1c1 100644 --- a/src/Umbraco.Core/Configuration/GlobalSettings.cs +++ b/src/Umbraco.Core/Configuration/GlobalSettings.cs @@ -20,7 +20,6 @@ namespace Umbraco.Core.Configuration public class GlobalSettings : IGlobalSettings { private readonly IIOHelper _ioHelper; - private readonly ISystemDirectories _systemDirectories; private string _localTempPath; // TODO these should not be static @@ -31,10 +30,9 @@ namespace Umbraco.Core.Configuration internal const string StaticReservedPaths = "~/app_plugins/,~/install/,~/mini-profiler-resources/,"; //must end with a comma! internal const string StaticReservedUrls = "~/config/splashes/noNodes.aspx,~/.well-known,"; //must end with a comma! - public GlobalSettings(IIOHelper ioHelper, ISystemDirectories systemDirectories) + public GlobalSettings(IIOHelper ioHelper) { _ioHelper = ioHelper; - _systemDirectories = systemDirectories; } /// @@ -168,7 +166,7 @@ namespace Umbraco.Core.Configuration } set { - SaveSetting(Constants.AppSettings.ConfigurationStatus, value, _ioHelper, _systemDirectories); + SaveSetting(Constants.AppSettings.ConfigurationStatus, value, _ioHelper); } } @@ -177,9 +175,9 @@ namespace Umbraco.Core.Configuration /// /// Key of the setting to be saved. /// Value of the setting to be saved. - internal static void SaveSetting(string key, string value, IIOHelper ioHelper, ISystemDirectories systemDirectories) + internal static void SaveSetting(string key, string value, IIOHelper ioHelper) { - var fileName = ioHelper.MapPath(string.Format("{0}/web.config", systemDirectories.Root)); + var fileName = ioHelper.MapPath(string.Format("{0}/web.config", ioHelper.Root)); var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace); var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single(); @@ -199,9 +197,9 @@ namespace Umbraco.Core.Configuration /// Removes a setting from the configuration file. /// /// Key of the setting to be removed. - internal static void RemoveSetting(string key, IIOHelper ioHelper, ISystemDirectories systemDirectories) + internal static void RemoveSetting(string key, IIOHelper ioHelper) { - var fileName = ioHelper.MapPath(string.Format("{0}/web.config", systemDirectories.Root)); + var fileName = ioHelper.MapPath(string.Format("{0}/web.config", ioHelper.Root)); var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace); var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single(); diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs index 50fad1b6d5..370f9d1f7a 100644 --- a/src/Umbraco.Core/IO/IOHelper.cs +++ b/src/Umbraco.Core/IO/IOHelper.cs @@ -115,7 +115,7 @@ namespace Umbraco.Core.IO } //use a tilde character instead of the complete path - public string ReturnPath(string settingsKey, string standardPath, bool useTilde) + private string ReturnPath(string settingsKey, string standardPath, bool useTilde) { var retval = ConfigurationManager.AppSettings[settingsKey]; @@ -125,7 +125,7 @@ namespace Umbraco.Core.IO return retval.TrimEnd('/'); } - public string ReturnPath(string settingsKey, string standardPath) + private string ReturnPath(string settingsKey, string standardPath) { return ReturnPath(settingsKey, standardPath, false); diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index 123793edae..d4647cbdd2 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -53,8 +53,6 @@ namespace Umbraco.Core.Runtime /// Gets the /// protected IIOHelper IOHelper { get; private set; } - protected ISystemDirectories SystemDirectories { get; private set; } - /// public IRuntimeState State => _state; @@ -82,10 +80,6 @@ namespace Umbraco.Core.Runtime if (TypeFinder == null) throw new InvalidOperationException($"The object returned from {nameof(GetTypeFinder)} cannot be null"); - SystemDirectories = GetSystemDirectories(); - if (SystemDirectories == null) - throw new InvalidOperationException($"The object returned from {nameof(GetSystemDirectories)} cannot be null"); - // the boot loader boots using a container scope, so anything that is PerScope will // be disposed after the boot loader has booted, and anything else will remain. // note that this REQUIRES that perWebRequestScope has NOT been enabled yet, else @@ -355,8 +349,6 @@ namespace Umbraco.Core.Runtime /// protected virtual IIOHelper GetIOHelper() => Umbraco.Core.IO.IOHelper.Default; - protected virtual ISystemDirectories GetSystemDirectories() - => new SystemDirectories(); /// /// Gets the application caches. @@ -390,7 +382,7 @@ namespace Umbraco.Core.Runtime /// protected virtual Configs GetConfigs() { - var configs = new ConfigsFactory(IOHelper, SystemDirectories).Create(); + var configs = new ConfigsFactory(IOHelper).Create(); return configs; } diff --git a/src/Umbraco.Core/UriExtensions.cs b/src/Umbraco.Core/UriExtensions.cs index 2cd7bef26d..8aedd8f263 100644 --- a/src/Umbraco.Core/UriExtensions.cs +++ b/src/Umbraco.Core/UriExtensions.cs @@ -52,7 +52,7 @@ namespace Umbraco.Core //if not, then def not back office if (isUmbracoPath == false) return false; - var mvcArea = globalSettings.GetUmbracoMvcArea(Current.SystemDirectories); + var mvcArea = globalSettings.GetUmbracoMvcArea(Current.IOHelper); //if its the normal /umbraco path if (urlPath.InvariantEquals("/" + mvcArea) || urlPath.InvariantEquals("/" + mvcArea + "/")) diff --git a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs index 722260fba7..c80b917784 100644 --- a/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs +++ b/src/Umbraco.Tests/Configurations/GlobalSettingsTests.cs @@ -17,13 +17,13 @@ namespace Umbraco.Tests.Configurations public override void SetUp() { base.SetUp(); - _root = Current.SystemDirectories.Root; + _root = Current.IOHelper.Root; } public override void TearDown() { base.TearDown(); - Current.SystemDirectories.Root = _root; + Current.IOHelper.Root = _root; } [Test] @@ -51,8 +51,8 @@ namespace Umbraco.Tests.Configurations var globalSettingsMock = Mock.Get(globalSettings); globalSettingsMock.Setup(x => x.Path).Returns(() => Current.IOHelper.ResolveUrl(path)); - Current.SystemDirectories.Root = rootPath; - Assert.AreEqual(outcome, globalSettings.GetUmbracoMvcAreaNoCache(new SystemDirectories())); + Current.IOHelper.Root = rootPath; + Assert.AreEqual(outcome, globalSettings.GetUmbracoMvcAreaNoCache(Core.IO.IOHelper.Default)); } diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs index 59f324387a..31cfcb7dc8 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs @@ -57,7 +57,7 @@ namespace Umbraco.Tests.PublishedContent var configs = TestHelper.GetConfigs(); Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs); - var globalSettings = new GlobalSettings(IOHelper.Default, new SystemDirectories()); + var globalSettings = new GlobalSettings(IOHelper.Default); configs.Add(SettingsForTests.GenerateMockUmbracoSettings); configs.Add(() => globalSettings); diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs index f6ad657a75..25ff5e233b 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs @@ -52,7 +52,7 @@ namespace Umbraco.Tests.PublishedContent var configs = TestHelper.GetConfigs(); Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs); - var globalSettings = new GlobalSettings(IOHelper.Default, new SystemDirectories()); + var globalSettings = new GlobalSettings(IOHelper.Default); configs.Add(SettingsForTests.GenerateMockUmbracoSettings); configs.Add(() => globalSettings); diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index b29d86f56b..de8322d737 100644 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -106,7 +106,7 @@ namespace Umbraco.Tests.Runtimes protected override Configs GetConfigs() { - var configs = new ConfigsFactory(Umbraco.Core.IO.IOHelper.Default, new SystemDirectories()).Create(); + var configs = new ConfigsFactory(Umbraco.Core.IO.IOHelper.Default).Create(); configs.Add(SettingsForTests.GetDefaultGlobalSettings); configs.Add(SettingsForTests.GetDefaultUmbracoSettings); return configs; diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs index 5ced1d66c9..6551ebf87a 100644 --- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs +++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs @@ -41,7 +41,7 @@ namespace Umbraco.Tests.TestHelpers public static IConfigsFactory GetConfigsFactory() { - return new ConfigsFactory(IOHelper.Default, new SystemDirectories()); + return new ConfigsFactory(IOHelper.Default); } /// diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index fdc43fee59..c963633aa0 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -229,7 +229,6 @@ namespace Umbraco.Tests.Testing Composition.RegisterUnique(); Composition.RegisterUnique(); Composition.RegisterUnique(); - Composition.RegisterUnique(); // register back office sections in the order we want them rendered Composition.WithCollectionBuilder().Append() diff --git a/src/Umbraco.Tests/Views/textpage.cshtml b/src/Umbraco.Tests/Views/textpage.cshtml deleted file mode 100644 index d7b4dce307..0000000000 --- a/src/Umbraco.Tests/Views/textpage.cshtml +++ /dev/null @@ -1,4 +0,0 @@ -@inherits Umbraco.Web.Mvc.UmbracoViewPage -@{ - Layout = null; -} \ No newline at end of file diff --git a/src/Umbraco.Web/AppBuilderExtensions.cs b/src/Umbraco.Web/AppBuilderExtensions.cs index 4259c8ebae..f740d57b79 100644 --- a/src/Umbraco.Web/AppBuilderExtensions.cs +++ b/src/Umbraco.Web/AppBuilderExtensions.cs @@ -51,7 +51,7 @@ namespace Umbraco.Web /// public static IAppBuilder UseSignalR(this IAppBuilder app, IGlobalSettings globalSettings) { - var umbracoPath = globalSettings.GetUmbracoMvcArea(Current.SystemDirectories); + var umbracoPath = globalSettings.GetUmbracoMvcArea(Current.IOHelper); var signalrPath = HttpRuntime.AppDomainAppVirtualPath + umbracoPath + "/BackOffice/signalr"; return app.MapSignalR(signalrPath, new HubConfiguration { EnableDetailedErrors = true }); } diff --git a/src/Umbraco.Web/Editors/AuthenticationController.cs b/src/Umbraco.Web/Editors/AuthenticationController.cs index 5da28bd0a5..363d3bb732 100644 --- a/src/Umbraco.Web/Editors/AuthenticationController.cs +++ b/src/Umbraco.Web/Editors/AuthenticationController.cs @@ -514,7 +514,7 @@ namespace Umbraco.Web.Editors var action = urlHelper.Action("ValidatePasswordResetCode", "BackOffice", new { - area = GlobalSettings.GetUmbracoMvcArea(Current.SystemDirectories), + area = GlobalSettings.GetUmbracoMvcArea(Current.IOHelper), u = userId, r = code }); diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index 028eea60e8..1276cc41d5 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -352,7 +352,7 @@ namespace Umbraco.Web.Editors if (defaultResponse == null) throw new ArgumentNullException("defaultResponse"); if (externalSignInResponse == null) throw new ArgumentNullException("externalSignInResponse"); - ViewData.SetUmbracoPath(GlobalSettings.GetUmbracoMvcArea(Current.SystemDirectories)); + ViewData.SetUmbracoPath(GlobalSettings.GetUmbracoMvcArea(Current.IOHelper)); //check if there is the TempData with the any token name specified, if so, assign to view bag and render the view if (ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) || diff --git a/src/Umbraco.Web/Editors/UsersController.cs b/src/Umbraco.Web/Editors/UsersController.cs index 9fcb1fc828..2cd284e307 100644 --- a/src/Umbraco.Web/Editors/UsersController.cs +++ b/src/Umbraco.Web/Editors/UsersController.cs @@ -456,7 +456,7 @@ namespace Umbraco.Web.Editors var action = urlHelper.Action("VerifyInvite", "BackOffice", new { - area = GlobalSettings.GetUmbracoMvcArea(Current.SystemDirectories), + area = GlobalSettings.GetUmbracoMvcArea(Current.IOHelper), invite = inviteToken }); diff --git a/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs b/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs index 04abb51b6f..7d8c7f1226 100644 --- a/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/DatabaseInstallStep.cs @@ -56,7 +56,7 @@ namespace Umbraco.Web.Install.InstallSteps // Remove legacy umbracoDbDsn configuration setting if it exists and connectionstring also exists if (ConfigurationManager.ConnectionStrings[Constants.System.UmbracoConnectionName] != null) { - GlobalSettings.RemoveSetting(Constants.System.UmbracoConnectionName, Current.IOHelper, Current.SystemDirectories); + GlobalSettings.RemoveSetting(Constants.System.UmbracoConnectionName, Current.IOHelper); } else { diff --git a/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs b/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs index 6c02d18822..8b4f84c2dd 100644 --- a/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs +++ b/src/Umbraco.Web/Mvc/AreaRegistrationExtensions.cs @@ -56,7 +56,7 @@ namespace Umbraco.Web.Mvc if (routes == null) throw new ArgumentNullException(nameof(routes)); if (defaultId == null) throw new ArgumentNullException(nameof(defaultId)); - var umbracoArea = globalSettings.GetUmbracoMvcArea(Current.SystemDirectories); + var umbracoArea = globalSettings.GetUmbracoMvcArea(Current.IOHelper); //routes are explicitly named with controller names and IDs var url = umbracoArea + "/" + diff --git a/src/Umbraco.Web/Mvc/BackOfficeArea.cs b/src/Umbraco.Web/Mvc/BackOfficeArea.cs index 747ebe61e1..5f257a9860 100644 --- a/src/Umbraco.Web/Mvc/BackOfficeArea.cs +++ b/src/Umbraco.Web/Mvc/BackOfficeArea.cs @@ -48,6 +48,6 @@ namespace Umbraco.Web.Mvc new[] {typeof (BackOfficeController).Namespace}); } - public override string AreaName => _globalSettings.GetUmbracoMvcArea(Current.SystemDirectories); + public override string AreaName => _globalSettings.GetUmbracoMvcArea(Current.IOHelper); } } diff --git a/src/Umbraco.Web/Runtime/WebInitialComponent.cs b/src/Umbraco.Web/Runtime/WebInitialComponent.cs index 247f2ce2c9..6edb1f0039 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComponent.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComponent.cs @@ -150,7 +150,7 @@ namespace Umbraco.Web.Runtime SurfaceControllerTypeCollection surfaceControllerTypes, UmbracoApiControllerTypeCollection apiControllerTypes) { - var umbracoPath = globalSettings.GetUmbracoMvcArea(Current.SystemDirectories); + var umbracoPath = globalSettings.GetUmbracoMvcArea(Current.IOHelper); // create the front-end route var defaultRoute = RouteTable.Routes.MapRoute( @@ -175,7 +175,7 @@ namespace Umbraco.Web.Runtime SurfaceControllerTypeCollection surfaceControllerTypes, UmbracoApiControllerTypeCollection apiControllerTypes) { - var umbracoPath = globalSettings.GetUmbracoMvcArea(Current.SystemDirectories); + var umbracoPath = globalSettings.GetUmbracoMvcArea(Current.IOHelper); // need to find the plugin controllers and route them var pluginControllers = surfaceControllerTypes.Concat(apiControllerTypes).ToArray();