diff --git a/src/Umbraco.Core/Composing/ReferenceResolver.cs b/src/Umbraco.Core/Composing/ReferenceResolver.cs index 61444c55ce..e9cf993a55 100644 --- a/src/Umbraco.Core/Composing/ReferenceResolver.cs +++ b/src/Umbraco.Core/Composing/ReferenceResolver.cs @@ -70,10 +70,9 @@ namespace Umbraco.Core.Composing } } - var assemblyNameToAssembly = assemblies.ToDictionary(x => x.GetName()); foreach (var item in assemblies) { - var classification = Resolve(item, assemblyNameToAssembly); + var classification = Resolve(item); if (classification == Classification.ReferencesUmbraco || classification == Classification.IsUmbraco) { applicationParts.Add(item); @@ -101,7 +100,7 @@ namespace Umbraco.Core.Composing return assembly.Location; } - private Classification Resolve(Assembly assembly, IDictionary assemblyNameToAssembly) + private Classification Resolve(Assembly assembly) { if (_classifications.TryGetValue(assembly, out var classification)) { @@ -124,10 +123,10 @@ namespace Umbraco.Core.Composing else { classification = Classification.DoesNotReferenceUmbraco; - foreach (var reference in GetReferences(assembly, assemblyNameToAssembly)) + foreach (var reference in GetReferences(assembly)) { // recurse - var referenceClassification = Resolve(reference, assemblyNameToAssembly); + var referenceClassification = Resolve(reference); if (referenceClassification == Classification.IsUmbraco || referenceClassification == Classification.ReferencesUmbraco) { @@ -142,7 +141,7 @@ namespace Umbraco.Core.Composing return classification; } - protected virtual IEnumerable GetReferences(Assembly assembly, IDictionary assemblyNameToAssembly) + protected virtual IEnumerable GetReferences(Assembly assembly) { var referencedAssemblies = assembly.GetReferencedAssemblies(); @@ -152,20 +151,7 @@ namespace Umbraco.Core.Composing if (TypeFinder.KnownAssemblyExclusionFilter.Any(f => referenceName.FullName.StartsWith(f, StringComparison.InvariantCultureIgnoreCase))) continue; - Assembly reference ; - try - { - reference = Assembly.Load(referenceName); - } - catch (Exception) - { - if (!assemblyNameToAssembly.TryGetValue(referenceName, out var item)) - { - continue; - } - - reference = Assembly.LoadFrom(item.Location); - } + var reference = Assembly.Load(referenceName); if (!_lookup.Contains(reference)) { diff --git a/src/Umbraco.Core/Composing/TypeFinder.cs b/src/Umbraco.Core/Composing/TypeFinder.cs index e1b355629e..5378283cc9 100644 --- a/src/Umbraco.Core/Composing/TypeFinder.cs +++ b/src/Umbraco.Core/Composing/TypeFinder.cs @@ -142,8 +142,10 @@ namespace Umbraco.Core.Composing "ServiceStack.", "SqlCE4Umbraco,", "Superpower,", // used by Serilog - // "System.", "System.Data.SqlClient,", + "System.Data.Odbc,", + "System.Data.OleDb,", + "System.Data.Entity,", "System.Runtime,", "System.Runtime.", "TidyNet,", diff --git a/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs b/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs index 4920e09d65..5637d84a89 100644 --- a/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs +++ b/src/Umbraco.Core/Install/InstallSteps/UpgradeStep.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Semver; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Web.Install.Models; @@ -28,9 +29,6 @@ namespace Umbraco.Web.Install.InstallSteps { get { - //TODO this will always compare the same version now - var newVersion = _umbracoVersion.SemanticVersion.ToString(); - string FormatGuidState(string value) { if (string.IsNullOrWhiteSpace(value)) value = "unknown"; @@ -39,14 +37,14 @@ namespace Umbraco.Web.Install.InstallSteps return value; } - var currentState = FormatGuidState(_runtimeState.CurrentMigrationState); var newState = FormatGuidState(_runtimeState.FinalMigrationState); - var currentVersion = _umbracoVersion.Current; + var newVersion = _umbracoVersion.SemanticVersion.ToString(); + var oldVersion = new SemVersion(_umbracoVersion.SemanticVersion.Major, 0, 0).ToString(); //TODO can we find the old version somehow? e.g. from current state - var reportUrl = $"https://our.umbraco.com/contribute/releases/compare?from={currentVersion}&to={newVersion}¬es=1"; + var reportUrl = $"https://our.umbraco.com/contribute/releases/compare?from={oldVersion}&to={newVersion}¬es=1"; - return new { currentVersion, newVersion, currentState, newState, reportUrl }; + return new { oldVersion, newVersion, currentState, newState, reportUrl }; } } } diff --git a/src/Umbraco.Infrastructure/RuntimeState.cs b/src/Umbraco.Infrastructure/RuntimeState.cs index 4f00e91e35..3f5e209858 100644 --- a/src/Umbraco.Infrastructure/RuntimeState.cs +++ b/src/Umbraco.Infrastructure/RuntimeState.cs @@ -97,35 +97,6 @@ namespace Umbraco.Core /// public void DetermineRuntimeLevel(IUmbracoDatabaseFactory databaseFactory, ILogger logger) { - // var localVersion = _umbracoVersion.LocalVersion; // the local, files, version - // var codeVersion = SemanticVersion; // the executing code version - var connect = false; - // - // if (localVersion == null) - // { - // // there is no local version, we are not installed - // logger.Debug("No local version, need to install Umbraco."); - // Level = RuntimeLevel.Install; - // Reason = RuntimeLevelReason.InstallNoVersion; - // return; - // } - // - // if (localVersion < codeVersion) - // { - // // there *is* a local version, but it does not match the code version - // // need to upgrade - // logger.Debug("Local version '{LocalVersion}' < code version '{CodeVersion}', need to upgrade Umbraco.", localVersion, codeVersion); - // Level = RuntimeLevel.Upgrade; - // Reason = RuntimeLevelReason.UpgradeOldVersion; - // } - // else if (localVersion > codeVersion) - // { - // logger.Warn("Local version '{LocalVersion}' > code version '{CodeVersion}', downgrading is not supported.", localVersion, codeVersion); - // - // // in fact, this is bad enough that we want to throw - // Reason = RuntimeLevelReason.BootFailedCannotDowngrade; - // throw new BootFailedException($"Local version \"{localVersion}\" > code version \"{codeVersion}\", downgrading is not supported."); - // } if (databaseFactory.Configured == false) { // local version *does* match code version, but the database is not configured @@ -139,6 +110,7 @@ namespace Umbraco.Core // else, keep going, // anything other than install wants a database - see if we can connect // (since this is an already existing database, assume localdb is ready) + var connect = false; var tries = _globalSettings.InstallMissingDatabase ? 2 : 5; for (var i = 0;;) { diff --git a/src/Umbraco.Web.Common/Install/InstallApiController.cs b/src/Umbraco.Web.Common/Install/InstallApiController.cs index 57a83bdc54..b074931fc1 100644 --- a/src/Umbraco.Web.Common/Install/InstallApiController.cs +++ b/src/Umbraco.Web.Common/Install/InstallApiController.cs @@ -10,6 +10,7 @@ using Umbraco.Core; using Umbraco.Core.Exceptions; using Umbraco.Core.Logging; using Umbraco.Core.Migrations.Install; +using Umbraco.Net; using Umbraco.Web.Common.Attributes; using Umbraco.Web.Install; using Umbraco.Web.Install.Models; @@ -23,17 +24,20 @@ namespace Umbraco.Web.Common.Install { private readonly DatabaseBuilder _databaseBuilder; private readonly InstallStatusTracker _installStatusTracker; + private readonly IRuntimeState _runtimeState; private readonly InstallStepCollection _installSteps; private readonly ILogger _logger; private readonly IProfilingLogger _proflog; public InstallApiController(DatabaseBuilder databaseBuilder, IProfilingLogger proflog, - InstallHelper installHelper, InstallStepCollection installSteps, InstallStatusTracker installStatusTracker) + InstallHelper installHelper, InstallStepCollection installSteps, InstallStatusTracker installStatusTracker, + IRuntimeState runtimeState) { _databaseBuilder = databaseBuilder ?? throw new ArgumentNullException(nameof(databaseBuilder)); _proflog = proflog ?? throw new ArgumentNullException(nameof(proflog)); _installSteps = installSteps; _installStatusTracker = installStatusTracker; + _runtimeState = runtimeState; InstallHelper = installHelper; _logger = _proflog; } diff --git a/src/Umbraco.Web.Common/Security/WebSecurity.cs b/src/Umbraco.Web.Common/Security/WebSecurity.cs deleted file mode 100644 index 7e0d5ac7f7..0000000000 --- a/src/Umbraco.Web.Common/Security/WebSecurity.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Security; -using Umbraco.Core; -using Umbraco.Core.Services; -using Umbraco.Core.Models.Membership; -using Microsoft.AspNetCore.Http; -using Umbraco.Core.Configuration; -using Umbraco.Core.Hosting; -using Umbraco.Core.Models; -using Umbraco.Web.Common.Extensions; -using Umbraco.Web.Security; - -namespace Umbraco.Web.Common.Security -{ - - /// - /// A utility class used for dealing with USER security in Umbraco - /// - public class WebSecurity : IWebSecurity - { - private IUser _currentUser; - - - public IUser CurrentUser - { - get => _currentUser; - set => _currentUser = value; - } - - public double PerformLogin(int userId) - { - return 15; - } - - public void ClearCurrentLogin() - { - - } - - public Attempt GetUserId() - { - return new Attempt(); - } - - public bool ValidateCurrentUser() - { - return false; - } - - public ValidateRequestAttempt ValidateCurrentUser(bool throwExceptions, bool requiresApproval = true) => throw new NotImplementedException(); - - public ValidateRequestAttempt AuthorizeRequest(bool throwExceptions = false) => throw new NotImplementedException(); - - public bool UserHasSectionAccess(string section, IUser user) => false; - - public bool IsAuthenticated() => false; - } -} diff --git a/src/Umbraco.Web.Common/UmbracoContext/UmbracoContextFactory.cs b/src/Umbraco.Web.Common/UmbracoContext/UmbracoContextFactory.cs index 70be6161f3..97f009968c 100644 --- a/src/Umbraco.Web.Common/UmbracoContext/UmbracoContextFactory.cs +++ b/src/Umbraco.Web.Common/UmbracoContext/UmbracoContextFactory.cs @@ -6,7 +6,6 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Hosting; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; -using Umbraco.Web.Common.Security; using Umbraco.Web.PublishedCache; using Umbraco.Web.Security; @@ -74,7 +73,7 @@ namespace Umbraco.Web _variationContextAccessor.VariationContext = new VariationContext(_defaultCultureAccessor.DefaultCulture); } - var webSecurity = new WebSecurity(); + IWebSecurity webSecurity = null; // TODO, we need to when users are migrated return new UmbracoContext( _publishedSnapshotService, diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.json b/src/Umbraco.Web.UI.NetCore/appsettings.json index a60391aeda..6cc0a49b4b 100644 --- a/src/Umbraco.Web.UI.NetCore/appsettings.json +++ b/src/Umbraco.Web.UI.NetCore/appsettings.json @@ -1,7 +1,5 @@ { - "ConnectionStrings": { - "umbracoDbDSN": "Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1;" - }, + "ConnectionStrings": {}, "Logging": { "LogLevel": { "Default": "Information", @@ -119,4 +117,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI/Umbraco/Install/Views/Index.cshtml b/src/Umbraco.Web.UI/Umbraco/Install/Views/Index.cshtml index e4a70e8c62..a15c2b9339 100644 --- a/src/Umbraco.Web.UI/Umbraco/Install/Views/Index.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/Install/Views/Index.cshtml @@ -1,6 +1,5 @@ @using Umbraco.Core.Configuration @using Umbraco.Web -@using Umbraco.Web.Install.Controllers @{ Layout = null; } diff --git a/src/Umbraco.Web/Macros/PartialViewMacroController.cs b/src/Umbraco.Web/Macros/PartialViewMacroController.cs new file mode 100644 index 0000000000..21d7b3292c --- /dev/null +++ b/src/Umbraco.Web/Macros/PartialViewMacroController.cs @@ -0,0 +1,42 @@ +using System.Web.Mvc; +using Umbraco.Web.Models; +using Umbraco.Web.Mvc; +using System.Linq; +using Umbraco.Core.Composing; +using Umbraco.Core.Models.PublishedContent; + +namespace Umbraco.Web.Macros +{ + /// + /// Controller to render macro content for Partial View Macros + /// + [MergeParentContextViewData] + [HideFromTypeFinder] // explicitly used: do *not* find and register it! + internal class PartialViewMacroController : Controller + { + private readonly MacroModel _macro; + private readonly IPublishedContent _content; + + public PartialViewMacroController(MacroModel macro, IPublishedContent content) + { + _macro = macro; + _content = content; + } + + /// + /// Child action to render a macro + /// + /// + [ChildActionOnly] + public PartialViewResult Index() + { + var model = new PartialViewMacroModel( + _content, + _macro.Id, + _macro.Alias, + _macro.Name, + _macro.Properties.ToDictionary(x => x.Key, x => (object)x.Value)); + return PartialView(_macro.MacroSource, model); + } + } +} diff --git a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs index ac36dad1ac..0773bc31ca 100644 --- a/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs +++ b/src/Umbraco.Web/Macros/PartialViewMacroEngine.cs @@ -76,17 +76,17 @@ namespace Umbraco.Web.Macros var request = new RequestContext(httpContext, routeVals); string output = String.Empty; - //TODO Render!! - // using (var controller = new PartialViewMacroController(macro, content)) - // { - // controller.ViewData = viewContext.ViewData; - // - // controller.ControllerContext = new ControllerContext(request, controller); - // - // //call the action to render - // var result = controller.Index(); - // output = controller.RenderViewResultAsString(result); - // } + + using (var controller = new PartialViewMacroController(macro, content)) + { + controller.ViewData = viewContext.ViewData; + + controller.ControllerContext = new ControllerContext(request, controller); + + //call the action to render + var result = controller.Index(); + output = controller.RenderViewResultAsString(result); + } return new MacroContent { Text = output }; } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 030e12d278..20b3067d47 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -145,6 +145,7 @@ +