From 2051caaa01a24f3b68dec8b737890fe9ff2da31a Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 12 Jul 2018 17:36:23 +0200 Subject: [PATCH] Post-merge fixes --- build/NuSpecs/tools/trees.config.install.xdt | 52 ++--- .../Install/DatabaseSchemaCreator.cs | 5 +- src/Umbraco.Core/Migrations/MigrationPlan.cs | 120 +++++++++-- .../Migrations/Upgrade/UmbracoPlan.cs | 197 +++++------------- .../ValueConverters/GridValueConverter.cs | 3 +- .../Services/Implement/RelationService.cs | 5 - .../FrontEnd/UmbracoHelperTests.cs | 23 +- .../Migrations/MigrationPlanTests.cs | 6 +- .../Umbraco/developer/Packages/installer.aspx | 2 +- .../config/EmbeddedMedia.Release.config | 78 +++---- .../config/EmbeddedMedia.config | 78 +++---- .../Editors/BackOfficeServerVariables.cs | 1 - .../DatabaseSchemaValidationHealthCheck.cs | 24 ++- ...elMapper.cs => DictionaryMapperProfile.cs} | 0 .../FlexibleDropdownPropertyValueConverter.cs | 12 +- src/Umbraco.Web/Umbraco.Web.csproj | 3 +- 16 files changed, 296 insertions(+), 313 deletions(-) rename src/Umbraco.Web/Models/Mapping/{DictionaryModelMapper.cs => DictionaryMapperProfile.cs} (100%) diff --git a/build/NuSpecs/tools/trees.config.install.xdt b/build/NuSpecs/tools/trees.config.install.xdt index 378d013c22..42adf3cb0e 100644 --- a/build/NuSpecs/tools/trees.config.install.xdt +++ b/build/NuSpecs/tools/trees.config.install.xdt @@ -4,18 +4,18 @@ - - - - @@ -23,39 +23,39 @@ - - - - - - - - - - @@ -66,12 +66,12 @@ - - @@ -80,17 +80,17 @@ xdt:Locator="Match(application,alias)" xdt:Transform="SetAttributes(sortOrder)" /> - - - - @@ -99,7 +99,7 @@ xdt:Transform="Remove" /> - @@ -111,30 +111,30 @@ xdt:Transform="Remove" /> - - - - - () { - var table = DefinitionFactory.GetTableDefinition(typeof(T), SqlSyntax); var tableName = table.Name; return SqlSyntax.DoesTableExist(_database, tableName); } + public bool TableExists() { + var table = DefinitionFactory.GetTableDefinition(typeof(T), SqlSyntax); + return table != null && TableExists(table.Name); } // this is used in tests internal void CreateTable(bool overwrite = false) diff --git a/src/Umbraco.Core/Migrations/MigrationPlan.cs b/src/Umbraco.Core/Migrations/MigrationPlan.cs index 7bf51d74f1..bea98feac3 100644 --- a/src/Umbraco.Core/Migrations/MigrationPlan.cs +++ b/src/Umbraco.Core/Migrations/MigrationPlan.cs @@ -97,12 +97,7 @@ namespace Umbraco.Core.Migrations throw new InvalidOperationException($"A transition from state \"{sourceState}\" has already been defined."); // register the transition - _transitions[sourceState] = new Transition - { - SourceState = sourceState, - TargetState = targetState, - MigrationType = migration - }; + _transitions[sourceState] = new Transition(sourceState, targetState, migration); // register the target state if we don't know it already // this is how we keep track of the final state - because @@ -112,7 +107,7 @@ namespace Umbraco.Core.Migrations _transitions.Add(targetState, null); _prevState = targetState; - _finalState = null; + _finalState = null; // force re-validation return this; } @@ -145,24 +140,87 @@ namespace Umbraco.Core.Migrations return this; } + /// + /// Copies a chain. + /// + /// Copies the chain going from startState to endState, with new states going from sourceState to targetState. + public MigrationPlan CopyChain(string sourceState, string startState, string endState, string targetState) + { + if (sourceState == null) throw new ArgumentNullException(nameof(sourceState)); + if (string.IsNullOrWhiteSpace(startState)) throw new ArgumentNullOrEmptyException(nameof(startState)); + if (string.IsNullOrWhiteSpace(endState)) throw new ArgumentNullOrEmptyException(nameof(endState)); + if (string.IsNullOrWhiteSpace(targetState)) throw new ArgumentNullOrEmptyException(nameof(targetState)); + if (sourceState == targetState) throw new ArgumentException("Source and target states cannot be identical."); + if (startState == endState) throw new ArgumentException("Start and end states cannot be identical."); + + sourceState = sourceState.Trim(); + startState = startState.Trim(); + endState = endState.Trim(); + targetState = targetState.Trim(); + + var state = startState; + var visited = new HashSet(); + + while (state != endState) + { + if (visited.Contains(state)) + throw new InvalidOperationException("A loop was detected in the copied chain."); + visited.Add(state); + + if (!_transitions.TryGetValue(state, out var transition)) + throw new InvalidOperationException($"There is no transition from state \"{sourceState}\"."); + + var newTargetState = transition.TargetState == endState + ? targetState + : Guid.NewGuid().ToString("B").ToUpper(); + Add(sourceState, newTargetState, transition.MigrationType); + sourceState = newTargetState; + state = transition.TargetState; + } + + return this; + } + + /// + /// Copies a chain. + /// + /// Copies the chain going from startState to endState, with new states going from chain to targetState. + public MigrationPlan CopyChain(string startState, string endState, string targetState) + => CopyChain(_prevState, startState, endState, targetState); + /// /// Gets the initial state. /// - /// The initial state is the state when no entry for the plan - /// could be found in the database (i.e. the plan has never run). + /// The initial state is the state when the plan has never + /// run. By default, it is the empty string, but plans may override + /// it if they have other ways of determining where to start from. public virtual string InitialState => string.Empty; /// /// Gets the final state. /// - public string FinalState => _finalState ?? (_finalState = Validate()); + public string FinalState + { + get + { + // modifying the plan clears _finalState + // Validate() either sets _finalState, or throws + if (_finalState == null) + Validate(); + + return _finalState; + } + } /// /// Validates the plan. /// /// The plan's final state. - public string Validate() + public void Validate() { + if (_finalState != null) + return; + // quick check for dead ends - a dead end is a transition that has a target state // that is not null and does not match any source state. such a target state has // been registered as a source state with a null transition. so there should be only @@ -194,7 +252,7 @@ namespace Umbraco.Core.Migrations verified.AddRange(visited); } - return finalState; + _finalState = finalState; } /// @@ -245,11 +303,43 @@ namespace Umbraco.Core.Migrations return origState; } + /// + /// Represents a plan transition. + /// private class Transition { - public string SourceState { get; set; } - public string TargetState { get; set; } - public Type MigrationType { get; set; } + /// + /// Initializes a new instance of the class. + /// + public Transition(string sourceState, string targetState, Type migrationTtype) + { + SourceState = sourceState; + TargetState = targetState; + MigrationType = migrationTtype; + } + + /// + /// Gets the source state. + /// + public string SourceState { get; } + + /// + /// Gets the target state. + /// + public string TargetState { get; } + + /// + /// Gets the migration type. + /// + public Type MigrationType { get; } + + /// + public override string ToString() + { + return MigrationType == typeof(NoopMigration) + ? $"{(SourceState == "" ? "" : SourceState)} --> {TargetState}" + : $"{SourceState} -- ({MigrationType.FullName}) --> {TargetState}"; + } } } } diff --git a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs index 698af341f7..3729ae1877 100644 --- a/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs +++ b/src/Umbraco.Core/Migrations/Upgrade/UmbracoPlan.cs @@ -3,14 +3,7 @@ using System.Configuration; using Semver; using Umbraco.Core.Configuration; using Umbraco.Core.Logging; -using Umbraco.Core.Migrations.Upgrade.V_7_10_0; using Umbraco.Core.Migrations.Upgrade.V_7_12_0; -using Umbraco.Core.Migrations.Upgrade.V_7_5_0; -using Umbraco.Core.Migrations.Upgrade.V_7_5_5; -using Umbraco.Core.Migrations.Upgrade.V_7_6_0; -using Umbraco.Core.Migrations.Upgrade.V_7_7_0; -using Umbraco.Core.Migrations.Upgrade.V_7_8_0; -using Umbraco.Core.Migrations.Upgrade.V_7_9_0; using Umbraco.Core.Migrations.Upgrade.V_8_0_0; namespace Umbraco.Core.Migrations.Upgrade @@ -38,7 +31,7 @@ namespace Umbraco.Core.Migrations.Upgrade /// /// The default initial state in plans is string.Empty. /// When upgrading from version 7, we want to use specific initial states - /// that are e.g. "{orig-7.9.3}", "{orig-7.11.1}", etc. so we can chain the proper + /// that are e.g. "{init-7.9.3}", "{init-7.11.1}", etc. so we can chain the proper /// migrations. /// This is also where we detect the current version, and reject invalid /// upgrades (from a tool old version, or going back in time, etc). @@ -51,65 +44,50 @@ namespace Umbraco.Core.Migrations.Upgrade if (!SemVersion.TryParse(ConfigurationManager.AppSettings["umbracoConfigurationStatus"], out var currentVersion)) throw new InvalidOperationException("Could not get current version from web.config umbracoConfigurationStatus appSetting."); - // must be at least 7.? - fixme adjust when releasing + // we currently support upgrading from 7.10.0 and later if (currentVersion < new SemVersion(7, 10)) - throw new InvalidOperationException($"Version {currentVersion} cannot be upgraded to {UmbracoVersion.SemanticVersion}."); + throw new InvalidOperationException($"Version {currentVersion} cannot be migrated to {UmbracoVersion.SemanticVersion}."); // cannot go back in time if (currentVersion > UmbracoVersion.SemanticVersion) throw new InvalidOperationException($"Version {currentVersion} cannot be downgraded to {UmbracoVersion.SemanticVersion}."); - switch (currentVersion.Major) - { - case 7: - // upgrading from version 7 - return "{orig-" + currentVersion + "}"; - case 8: // fixme remove when releasing - // upgrading from version 8 - // should never happen, this is very temp and for my own website - zpqrtbnk - return "{04F54303-3055-4700-8F76-35A37F232FF5}"; // right before the variants migration - default: - throw new InvalidOperationException($"Version {currentVersion} is not supported by the migration plan."); - } + // upgrading from version 7 => initial state is eg "{init-7.10.0}" + // anything else is not supported - ie if 8 and above, we should have an initial state already + if (currentVersion.Major != 7) + throw new InvalidOperationException($"Version {currentVersion} is not supported by the migration plan."); + return "{init-" + currentVersion + "}"; } } /// protected override void DefinePlan() { - // NOTE: MODIFYING THE PLAN + // MODIFYING THE PLAN // // Please take great care when modifying the plan! // // * Creating a migration for version 8: - // Append the migration to the main version 8 chain, using a new guid. - // Update the final state (see end of file) to that guid. - // Append the migration to version 7 upgrade chains. - // * Porting a migration from version 7: - // Append the migration to the main version 8 chain, using a new guid. - // Update the final state (see end of file) to that guid. - // Update all init-7.x.y chains. - - - // UPGRADE FROM 7, OLDEST + // Append the migration to the main chain, using a new guid, before the "//FINAL" comment // - // When upgrading from version 7, the state is automatically set to {init-7.x.y} where - // 7.x.y is the version. We need to define a chain starting at that state and taking - // us to version 8. And we need such a chain for each 7.x.y version that can be upgraded - // to version 8, bearing in mind that new releases of version 7 will probably be - // created *after* the first released of version 8. + // If the new migration causes a merge conflict, because someone else also added another + // new migration, you NEED to fix the conflict by providing one default path, and paths + // out of the conflict states (see example below). // - // fixme adjust when releasing the first public (alpha?) version + // * Porting from version 7: + // Append the ported migration to the main chain, using a new guid (same as above). + // Create a new special chain from the {init-...} state to the main chain (see example + // below). - // we don't support upgrading from versions older than 7.? - // and then we only need to run v8 migrations + + // plan starts at 7.10.0 (anything before 7.10.0 is not supported) + // upgrades from 7 to 8, and then takes care of all eventual upgrades // From("{init-7.10.0}"); - Chain("{7C447271-CA3F-4A6A-A913-5D77015655CB}"); + Chain("{7C447271-CA3F-4A6A-A913-5D77015655CB}"); Chain("{CBFF58A2-7B50-4F75-8E98-249920DB0F37}"); Chain("{3D18920C-E84D-405C-A06A-B7CEE52FE5DD}"); - Chain("{FB0A5429-587E-4BD0-8A67-20F0E7E62FF7}"); Chain("{F0C42457-6A3B-4912-A7EA-F27ED85A2092}"); Chain("{8640C9E4-A1C0-4C59-99BB-609B4E604981}"); @@ -117,122 +95,45 @@ namespace Umbraco.Core.Migrations.Upgrade Chain("{9DF05B77-11D1-475C-A00A-B656AF7E0908}"); Chain("{6FE3EF34-44A0-4992-B379-B40BC4EF1C4D}"); Chain("{7F59355A-0EC9-4438-8157-EB517E6D2727}"); - Chain("{66B6821A-0DE3-4DF8-A6A4-65ABD211EDDE}"); - Chain("{49506BAE-CEBB-4431-A1A6-24AD6EBBBC57}"); - Chain("{083A9894-903D-41B7-B6B3-9EAF2D4CCED0}"); - Chain("{42097524-0F8C-482C-BD79-AC7407D8A028}"); - Chain("{3608CD41-792A-4E9A-A97D-42A5E797EE31}"); - Chain("{608A02B8-B1A1-4C24-8955-0B95DB1F567E}"); - // must chain to v8 final state (see at end of file) - Chain("{1350617A-4930-4D61-852F-E3AA9E692173}"); - - - // UPGRADE FROM 7, MORE RECENT - // - // handle more recent versions - not yet - - // for more recent versions... - // 7.10.x = same as 7.10.0? - //From("{init-7.10.1}").Chain("{init-7.10.0}"); - - - // VERSION 8 PLAN - // - // this is the master Umbraco migration plan, starting from the very first version 8 - // release, which was a pre-pre-alpha, years ago. It contains migrations created - // for version 8, along with migrations ported from version 7 as version 7 evolves. - // It is therefore *normal* that some pure version 8 migrations are mixed with - // migrations merged from version 7. - // - // new migrations should always be *appended* to the *end* of the chain. - - // 8.0.0 - From("{init-origin}"); // "origin" was 7.4.something - Chain("{98347B5E-65BF-4DD7-BB43-A09CB7AF4FCA}"); - Chain("{1E8165C4-942D-40DC-AC76-C5FF8831E400}"); - Chain("{39E15568-7AAD-4D54-81D0-758CCFC529F8}"); - Chain("{55C3F97D-BDA7-4FB1-A743-B0456B56EAA3}"); - - // merging from 7.5.0 - Chain("{287F9E39-F673-42F7-908C-21659AB13B13}"); - Chain("{2D08588A-AD90-479C-9F6E-A99B60BA7226}"); - Chain("{2D917FF8-AC81-4C00-A407-1F4B1DF6089C}"); - - // merging from 7.5.5 - Chain("{44484C32-EEB3-4A12-B1CB-11E02CE22AB2}"); - - // merging from 7.6.0 - Chain("{3586E4E9-2922-49EB-8E2A-A530CE6DBDE0}"); - Chain("{D4A5674F-654D-4CC7-85E5-CFDBC533A318}"); - Chain("{7F828EDD-6622-4A8D-AD80-EEAF46C11680}"); - Chain("{F30AC223-D277-4D1F-B2AB-F0F0D3546CE1}"); - Chain("{7C27E310-CF48-4637-A22E-8D87355161C1}"); - Chain("{7D2ABA16-EE48-4569-8827-E81370FC4871}"); - Chain("{02879EDF-13A8-43AF-87A5-DD85723D0016}"); - Chain("{5496C6CC-3AE0-4789-AF49-5BB4E28FA424}"); - Chain("{8995332B-085E-4C0C-849E-9A77E79F4293}"); - - // merging from 7.7.0 - Chain("{74319856-7681-46B1-AA0D-F7E896FBE6A1}"); - Chain("{0427B0A2-994A-4AB4-BFF3-31B20614F6C9}"); - Chain("{F0D6F782-E432-46DE-A3A7-2AF06DB8853B}"); - Chain("{AEB2BA2B-71E4-4B1B-AB6C-CEFB7F06FEEB}"); - Chain("{B5A6C799-B91E-496F-A1FE-7B4FE98BF6AB}"); - Chain("{04F54303-3055-4700-8F76-35A37F232FF5}"); - - // 8.0.0 - Chain("{6550C7E8-77B7-4DE3-9B58-E31C81CB9504}"); - Chain("{E3388F73-89FA-45FE-A539-C7FACC8D63DD}"); - Chain("{82C4BA1D-7720-46B1-BBD7-07F3F73800E6}"); - Chain("{139F26D7-7E08-48E3-81D9-E50A21A72F67}"); - Chain("{CC1B1201-1328-443C-954A-E0BBB8CCC1B5}"); - Chain("{CA7DB949-3EF4-403D-8464-F9BA36A52E87}"); - Chain("{7F0BF916-F64E-4B25-864A-170D6E6B68E5}"); - - // merging from 7.8.0 - Chain("{FDCB727A-EFB6-49F3-89E4-A346503AB849}"); - Chain("{2A796A08-4FE4-4783-A1A5-B8A6C8AA4A92}"); - Chain("{1A46A98B-2AAB-4C8E-870F-A2D55A97FD1F}"); - Chain("{0AE053F6-2683-4234-87B2-E963F8CE9498}"); - Chain("{D454541C-15C5-41CF-8109-937F26A78E71}"); - - // merging from 7.9.0 - Chain("{89A728D1-FF4C-4155-A269-62CC09AD2131}"); - Chain("{FD8631BC-0388-425C-A451-5F58574F6F05}"); - Chain("{2821F53E-C58B-4812-B184-9CD240F990D7}"); - Chain("{8918450B-3DA0-4BB7-886A-6FA8B7E4186E}"); - - // mergin from 7.10.0 - Chain("{79591E91-01EA-43F7-AC58-7BD286DB1E77}"); - - // mergin from 7.12.0 - Chain("{4BCD4198-6822-4D82-8C69-6CC4086DF46A}"); - - // 8.0.0 // AddVariationTables1 has been superceeded by AddVariationTables2 //Chain("{941B2ABA-2D06-4E04-81F5-74224F1DB037}"); Chain("{76DF5CD7-A884-41A5-8DC6-7860D95B1DF5}"); - - // however, need to take care of ppl in post-AddVariationTables1 state + // however, provide a path out of the old state Add("{941B2ABA-2D06-4E04-81F5-74224F1DB037}", "{76DF5CD7-A884-41A5-8DC6-7860D95B1DF5}"); + // resume at {76DF5CD7-A884-41A5-8DC6-7860D95B1DF5} ... - // 8.0.0 Chain("{A7540C58-171D-462A-91C5-7A9AA5CB8BFD}"); - - // merge - Chain("{3E44F712-E2E3-473A-AE49-5D7F8E67CE3F}"); // shannon added that one - let's keep it as the default path - Chain("{4CACE351-C6B9-4F0C-A6BA-85A02BBD39E4}"); // then add stephan's - to new final state - //Chain("{65D6B71C-BDD5-4A2E-8D35-8896325E9151}"); // stephan added that one - need a path to final state - Add("{65D6B71C-BDD5-4A2E-8D35-8896325E9151}", "{4CACE351-C6B9-4F0C-A6BA-85A02BBD39E4}"); - // 8.0.0 + Chain("{3E44F712-E2E3-473A-AE49-5D7F8E67CE3F}"); // shannon added that one - let's keep it as the default path + //Chain("{65D6B71C-BDD5-4A2E-8D35-8896325E9151}"); // stephan added that one = merge conflict, remove, + Chain("{4CACE351-C6B9-4F0C-A6BA-85A02BBD39E4}"); // but it after shannon's, with a new target state, + Add("{65D6B71C-BDD5-4A2E-8D35-8896325E9151}", "{4CACE351-C6B9-4F0C-A6BA-85A02BBD39E4}"); // and provide a path out of the conflict state + // resume at {4CACE351-C6B9-4F0C-A6BA-85A02BBD39E4} ... + Chain("{1350617A-4930-4D61-852F-E3AA9E692173}"); + Chain("{39E5B1F7-A50B-437E-B768-1723AEC45B65}"); // from 7.12.0 + //FINAL - // FINAL STATE - MUST MATCH LAST ONE ABOVE ! - // whenever this changes, update all references in this file! - Add(string.Empty, "{1350617A-4930-4D61-852F-E3AA9E692173}"); + + + // and then, need to support upgrading from more recent 7.x + // + From("{init-7.10.1}").Chain("{init-7.10.0}"); // same as 7.10.0 + From("{init-7.10.2}").Chain("{init-7.10.0}"); // same as 7.10.0 + From("{init-7.10.3}").Chain("{init-7.10.0}"); // same as 7.10.0 + From("{init-7.10.4}").Chain("{init-7.10.0}"); // same as 7.10.0 + From("{init-7.11.0}").Chain("{init-7.10.0}"); // same as 7.10.0 + From("{init-7.11.1}").Chain("{init-7.10.0}"); // same as 7.10.0 + + // 7.12.0 has a migration, define a custom chain which copies the chain + // going from {init-7.10.0} to former final, and then goes straight to + // main chain, skipping the migration + // + From("{init-7.12.0}"); + // copy from copy to (former final) main chain + CopyChain("{init-7.10.0}", "{1350617A-4930-4D61-852F-E3AA9E692173}", "{39E5B1F7-A50B-437E-B768-1723AEC45B65}"); } } } diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs index e1729a22de..5a642bedc7 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/GridValueConverter.cs @@ -48,13 +48,12 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters //TODO: Change all singleton access to use ctor injection in v8!!! //TODO: That would mean that property value converters would need to be request lifespan, hrm.... - bool isDebug = HttpContext.Current != null && HttpContext.Current.IsDebuggingEnabled; var gridConfig = UmbracoConfig.For.GridConfig( Current.ProfilingLogger.Logger, Current.ApplicationCache.RuntimeCache, new DirectoryInfo(IOHelper.MapPath(SystemDirectories.AppPlugins)), new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)), - isDebug); + Current.RuntimeState.Debug); var sections = GetArray(obj, "sections"); foreach (var section in sections.Cast()) diff --git a/src/Umbraco.Core/Services/Implement/RelationService.cs b/src/Umbraco.Core/Services/Implement/RelationService.cs index 14cd63c63d..a4c1b977a0 100644 --- a/src/Umbraco.Core/Services/Implement/RelationService.cs +++ b/src/Umbraco.Core/Services/Implement/RelationService.cs @@ -217,8 +217,6 @@ namespace Umbraco.Core.Services.Implement { using (var scope = ScopeProvider.CreateScope(autoComplete: true)) { - - var rtQuery = Query().Where(x => x.Alias == relationTypeAlias); var relationType = _relationTypeRepository.Get(rtQuery).FirstOrDefault(); if (relationType == null) @@ -244,7 +242,6 @@ namespace Umbraco.Core.Services.Implement relationTypeIds = relationTypes.Select(x => x.Id).ToList(); } - return relationTypeIds.Count == 0 ? Enumerable.Empty() : GetRelationsByListOfTypeIds(relationTypeIds); @@ -265,7 +262,6 @@ namespace Umbraco.Core.Services.Implement relationTypeIds = relationTypes.Select(x => x.Id).ToList(); } - return relationTypeIds.Count == 0 ? Enumerable.Empty() : GetRelationsByListOfTypeIds(relationTypeIds); @@ -668,7 +664,6 @@ namespace Umbraco.Core.Services.Implement var relations = new List(); using (var scope = ScopeProvider.CreateScope(autoComplete: true)) { - foreach (var relationTypeId in relationTypeIds) { var id = relationTypeId; diff --git a/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs b/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs index a0e80a33cf..3d6d380fe9 100644 --- a/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs +++ b/src/Umbraco.Tests/FrontEnd/UmbracoHelperTests.cs @@ -9,7 +9,6 @@ using Umbraco.Tests.TestHelpers; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Logging; -using Umbraco.Tests.TestHelpers; using Umbraco.Web; namespace Umbraco.Tests.FrontEnd @@ -20,6 +19,12 @@ namespace Umbraco.Tests.FrontEnd private const string SampleWithAnchorElement = "Hello world, this is some text with a link"; private const string SampleWithBoldAndAnchorElements = "Hello world, this is some text with a link"; + [TearDown] + public void TearDown() + { + Current.Reset(); + } + [Test] public static void Truncate_Simple() { @@ -340,9 +345,10 @@ namespace Umbraco.Tests.FrontEnd /// running. /// [Test] - public static void Converting_string_udi_to_a_udi_returns_original_udi_value() + public void Converting_string_udi_to_a_udi_returns_original_udi_value() { // Arrange + SetUpDependencyContainer(); Udi.ResetUdiTypes(); Udi sample = new GuidUdi(Constants.UdiEntityType.AnyGuid, Guid.NewGuid()); @@ -362,9 +368,10 @@ namespace Umbraco.Tests.FrontEnd /// running. /// [Test] - public static void Converting_hello_to_a_udi_returns_false() + public void Converting_hello_to_a_udi_returns_false() { // Arrange + SetUpDependencyContainer(); Udi.ResetUdiTypes(); const string sample = "Hello"; @@ -557,8 +564,6 @@ namespace Umbraco.Tests.FrontEnd ); // Assert - ResetDependencyContainer(); - Assert.IsTrue(success); Assert.That(result, Is.EqualTo(sample)); } @@ -579,8 +584,6 @@ namespace Umbraco.Tests.FrontEnd ); // Assert - ResetDependencyContainer(); - Assert.IsTrue(success); Assert.That(result, Is.EqualTo(sample)); } @@ -601,8 +604,6 @@ namespace Umbraco.Tests.FrontEnd ); // Assert - ResetDependencyContainer(); - Assert.IsFalse(success); Assert.That(result, Is.Null); } @@ -623,8 +624,6 @@ namespace Umbraco.Tests.FrontEnd ); // Assert - ResetDependencyContainer(); - Assert.IsFalse(success); Assert.That(result, Is.Null); } @@ -646,7 +645,5 @@ namespace Umbraco.Tests.FrontEnd Current.Container = container.Object; } - - private void ResetDependencyContainer() => Current.Reset(); } } diff --git a/src/Umbraco.Tests/Migrations/MigrationPlanTests.cs b/src/Umbraco.Tests/Migrations/MigrationPlanTests.cs index 91673af480..ee1b2a56f5 100644 --- a/src/Umbraco.Tests/Migrations/MigrationPlanTests.cs +++ b/src/Umbraco.Tests/Migrations/MigrationPlanTests.cs @@ -133,9 +133,9 @@ namespace Umbraco.Tests.Migrations public void ValidateUmbracoPlan() { var plan = new UmbracoPlan(Mock.Of(), Mock.Of()); - var finalState = plan.Validate(); - Console.WriteLine(finalState); - Assert.IsFalse(string.IsNullOrWhiteSpace(finalState)); + plan.Validate(); + Console.WriteLine(plan.FinalState); + Assert.IsFalse(string.IsNullOrWhiteSpace(plan.FinalState)); } public class DeleteRedirectUrlTable : MigrationBase diff --git a/src/Umbraco.Web.UI/Umbraco/developer/Packages/installer.aspx b/src/Umbraco.Web.UI/Umbraco/developer/Packages/installer.aspx index 37dca8400e..1beda45dae 100644 --- a/src/Umbraco.Web.UI/Umbraco/developer/Packages/installer.aspx +++ b/src/Umbraco.Web.UI/Umbraco/developer/Packages/installer.aspx @@ -1,6 +1,6 @@ <%@ Page Language="c#" MasterPageFile="../../masterpages/umbracoPage.Master" AutoEventWireup="True" Inherits="umbraco.presentation.developer.packages.Installer" Trace="false" ValidateRequest="false" %> -<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %> +<%@ Register TagPrefix="cc1" Namespace="Umbraco.Web._Legacy.Controls" Assembly="Umbraco.Web" %> diff --git a/src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config b/src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config index df0919b0f0..32a165399c 100644 --- a/src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config +++ b/src/Umbraco.Web.UI/config/EmbeddedMedia.Release.config @@ -1,134 +1,134 @@ - + - + - + - + xml - + - + - + - + - + - + - + - + - + - + - + - + - + - + json - + - + - + - + - + - + 1 xml https - + - + - + - + xml - + - + xml - + - + - + - + - + - + - + - + - + diff --git a/src/Umbraco.Web.UI/config/EmbeddedMedia.config b/src/Umbraco.Web.UI/config/EmbeddedMedia.config index 0bbb0f15a7..ac8c5cc901 100644 --- a/src/Umbraco.Web.UI/config/EmbeddedMedia.config +++ b/src/Umbraco.Web.UI/config/EmbeddedMedia.config @@ -1,134 +1,134 @@  - + - + - + - + xml - + - + - + - + - + - + - + - + - + - + - + - + - + - + json - + - + - + - + - + - + 1 xml https - + - + - + - + xml - + - + xml - + - + - + - + - + - + - + - + - + diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index 88cd4905d5..5e91cbe853 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -297,7 +297,6 @@ namespace Umbraco.Web.Editors "languageApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetAllLanguages()) } - } }, { diff --git a/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/DatabaseSchemaValidationHealthCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/DatabaseSchemaValidationHealthCheck.cs index 6ea562b2c7..569373f0bb 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/DatabaseSchemaValidationHealthCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/DataIntegrity/DatabaseSchemaValidationHealthCheck.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; -using Umbraco.Core; +using System; +using System.Collections.Generic; using Umbraco.Core.Logging; +using Umbraco.Core.Migrations.Install; using Umbraco.Core.Services; namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity @@ -15,13 +16,15 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity Group = "Data Integrity")] public class DatabaseSchemaValidationHealthCheck : HealthCheck { - private readonly DatabaseContext _databaseContext; + private readonly DatabaseBuilder _databaseBuilder; private readonly ILocalizedTextService _textService; + private readonly ILogger _logger; - public DatabaseSchemaValidationHealthCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext) + public DatabaseSchemaValidationHealthCheck(DatabaseBuilder databaseBuilder, ILocalizedTextService textService, ILogger logger) { - _databaseContext = HealthCheckContext.ApplicationContext.DatabaseContext; - _textService = healthCheckContext.ApplicationContext.Services.TextService; + _databaseBuilder = databaseBuilder ?? throw new ArgumentNullException(nameof(databaseBuilder)); + _textService = textService ?? throw new ArgumentNullException(nameof(textService)); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public override HealthCheckStatus ExecuteAction(HealthCheckAction action) @@ -37,20 +40,23 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity private HealthCheckStatus CheckDatabase() { - var results = _databaseContext.ValidateDatabaseSchema(); + var results = _databaseBuilder.ValidateDatabaseSchema(); + + _logger.Warn(typeof(DatabaseSchemaValidationHealthCheck), _textService.Localize("databaseSchemaValidationCheckDatabaseLogMessage")); - LogHelper.Warn(typeof(DatabaseSchemaValidationHealthCheck), _textService.Localize("databaseSchemaValidationCheckDatabaseLogMessage")); foreach(var error in results.Errors) { - LogHelper.Warn(typeof(DatabaseSchemaValidationHealthCheck), error.Item1 + ": " + error.Item2); + _logger.Warn(typeof(DatabaseSchemaValidationHealthCheck), error.Item1 + ": " + error.Item2); } if(results.Errors.Count > 0) + { return new HealthCheckStatus(_textService.Localize("healthcheck/databaseSchemaValidationCheckDatabaseErrors", new[] { results.Errors.Count.ToString() })) { ResultType = StatusResultType.Error, View = "Umbraco.Dashboard.DatabaseSchemaValidationController" }; + } return new HealthCheckStatus(_textService.Localize("healthcheck/databaseSchemaValidationCheckDatabaseOk")) { diff --git a/src/Umbraco.Web/Models/Mapping/DictionaryModelMapper.cs b/src/Umbraco.Web/Models/Mapping/DictionaryMapperProfile.cs similarity index 100% rename from src/Umbraco.Web/Models/Mapping/DictionaryModelMapper.cs rename to src/Umbraco.Web/Models/Mapping/DictionaryMapperProfile.cs diff --git a/src/Umbraco.Web/PropertyEditors/ValueConverters/FlexibleDropdownPropertyValueConverter.cs b/src/Umbraco.Web/PropertyEditors/ValueConverters/FlexibleDropdownPropertyValueConverter.cs index eb77ae0edd..5fa537f561 100644 --- a/src/Umbraco.Web/PropertyEditors/ValueConverters/FlexibleDropdownPropertyValueConverter.cs +++ b/src/Umbraco.Web/PropertyEditors/ValueConverters/FlexibleDropdownPropertyValueConverter.cs @@ -1,23 +1,18 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using Umbraco.Core; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Services; namespace Umbraco.Web.PropertyEditors.ValueConverters { [DefaultPropertyValueConverter] public class FlexibleDropdownPropertyValueConverter : PropertyValueConverterBase { - public FlexibleDropdownPropertyValueConverter() - { - } - public override bool IsConverter(PublishedPropertyType propertyType) { - return propertyType.EditorAlias.Equals(Umbraco.Core.Constants.PropertyEditors.Aliases.DropDownListFlexible); + return propertyType.EditorAlias.Equals(Constants.PropertyEditors.Aliases.DropDownListFlexible); } public override object ConvertSourceToIntermediate(IPublishedElement owner, PublishedPropertyType propertyType, object source, bool preview) @@ -51,7 +46,6 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters return propertyType.DataType.ConfigurationAs().Multiple ? typeof(IEnumerable) : typeof(string); - } - + } } } diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index aedbd6e771..0c76aedc80 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -131,6 +131,7 @@ + @@ -241,7 +242,7 @@ - +