diff --git a/src/Umbraco.Core/Components/RequireAttribute.cs b/src/Umbraco.Core/Components/ComposeAfterAttribute.cs similarity index 87% rename from src/Umbraco.Core/Components/RequireAttribute.cs rename to src/Umbraco.Core/Components/ComposeAfterAttribute.cs index 472c3ddf12..a8fdfaa92b 100644 --- a/src/Umbraco.Core/Components/RequireAttribute.cs +++ b/src/Umbraco.Core/Components/ComposeAfterAttribute.cs @@ -18,13 +18,13 @@ namespace Umbraco.Core.Components /// declared as strong (and at least one composer must be enabled). /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)] - public sealed class RequireAttribute : Attribute + public sealed class ComposeAfterAttribute : Attribute { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The type of the required composer. - public RequireAttribute(Type requiredType) + public ComposeAfterAttribute(Type requiredType) { if (typeof(IComposer).IsAssignableFrom(requiredType) == false) throw new ArgumentException($"Type {requiredType.FullName} is invalid here because it does not implement {typeof(IComposer).FullName}."); @@ -32,11 +32,11 @@ namespace Umbraco.Core.Components } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The type of the required composer. /// A value indicating whether the requirement is weak. - public RequireAttribute(Type requiredType, bool weak) + public ComposeAfterAttribute(Type requiredType, bool weak) : this(requiredType) { Weak = weak; diff --git a/src/Umbraco.Core/Components/RequiredByAttribute.cs b/src/Umbraco.Core/Components/ComposeBeforeAttribute.cs similarity index 89% rename from src/Umbraco.Core/Components/RequiredByAttribute.cs rename to src/Umbraco.Core/Components/ComposeBeforeAttribute.cs index 5da7745892..17065d1676 100644 --- a/src/Umbraco.Core/Components/RequiredByAttribute.cs +++ b/src/Umbraco.Core/Components/ComposeBeforeAttribute.cs @@ -19,13 +19,13 @@ namespace Umbraco.Core.Components /// [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)] - public sealed class RequiredByAttribute : Attribute + public sealed class ComposeBeforeAttribute : Attribute { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The type of the required composer. - public RequiredByAttribute(Type requiringType) + public ComposeBeforeAttribute(Type requiringType) { if (typeof(IComposer).IsAssignableFrom(requiringType) == false) throw new ArgumentException($"Type {requiringType.FullName} is invalid here because it does not implement {typeof(IComposer).FullName}."); diff --git a/src/Umbraco.Core/Components/Composers.cs b/src/Umbraco.Core/Components/Composers.cs index cc65e351b5..0dbd95b84c 100644 --- a/src/Umbraco.Core/Components/Composers.cs +++ b/src/Umbraco.Core/Components/Composers.cs @@ -136,20 +136,20 @@ namespace Umbraco.Core.Components var type = kvp.Key; text.AppendLine(type.FullName); - foreach (var attribute in type.GetCustomAttributes()) + foreach (var attribute in type.GetCustomAttributes()) text.AppendLine(" -> " + attribute.RequiredType + (attribute.Weak.HasValue ? (attribute.Weak.Value ? " (weak)" : (" (strong" + (requirements.ContainsKey(attribute.RequiredType) ? ", missing" : "") + ")")) : "")); - foreach (var attribute in type.GetCustomAttributes()) + foreach (var attribute in type.GetCustomAttributes()) text.AppendLine(" -< " + attribute.RequiringType); foreach (var i in type.GetInterfaces()) { text.AppendLine(" : " + i.FullName); - foreach (var attribute in i.GetCustomAttributes()) + foreach (var attribute in i.GetCustomAttributes()) text.AppendLine(" -> " + attribute.RequiredType + (attribute.Weak.HasValue ? (attribute.Weak.Value ? " (weak)" : (" (strong" + (requirements.ContainsKey(attribute.RequiredType) ? ", missing" : "") + ")")) : "")); - foreach (var attribute in i.GetCustomAttributes()) + foreach (var attribute in i.GetCustomAttributes()) text.AppendLine(" -< " + attribute.RequiringType); } if (kvp.Value != null) @@ -208,8 +208,8 @@ namespace Umbraco.Core.Components // get 'require' attributes // these attributes are *not* inherited because we want to "custom-inherit" for interfaces only var requireAttributes = type - .GetInterfaces().SelectMany(x => x.GetCustomAttributes()) // those marking interfaces - .Concat(type.GetCustomAttributes()); // those marking the composer + .GetInterfaces().SelectMany(x => x.GetCustomAttributes()) // those marking interfaces + .Concat(type.GetCustomAttributes()); // those marking the composer // what happens in case of conflicting attributes (different strong/weak for same type) is not specified. foreach (var attr in requireAttributes) @@ -249,8 +249,8 @@ namespace Umbraco.Core.Components // get 'required' attributes // these attributes are *not* inherited because we want to "custom-inherit" for interfaces only var requiredAttributes = type - .GetInterfaces().SelectMany(x => x.GetCustomAttributes()) // those marking interfaces - .Concat(type.GetCustomAttributes()); // those marking the composer + .GetInterfaces().SelectMany(x => x.GetCustomAttributes()) // those marking interfaces + .Concat(type.GetCustomAttributes()); // those marking the composer foreach (var attr in requiredAttributes) { diff --git a/src/Umbraco.Core/Components/ICoreComposer.cs b/src/Umbraco.Core/Components/ICoreComposer.cs index 810d9641be..94aa9953a9 100644 --- a/src/Umbraco.Core/Components/ICoreComposer.cs +++ b/src/Umbraco.Core/Components/ICoreComposer.cs @@ -7,7 +7,7 @@ /// All core composers are required by (compose before) all user composers, /// and require (compose after) all runtime composers. /// - [Require(typeof(IRuntimeComposer))] + [ComposeAfter(typeof(IRuntimeComposer))] public interface ICoreComposer : IComposer { } } \ No newline at end of file diff --git a/src/Umbraco.Core/Components/IUserComposer.cs b/src/Umbraco.Core/Components/IUserComposer.cs index ca8cfcaefb..59e0023635 100644 --- a/src/Umbraco.Core/Components/IUserComposer.cs +++ b/src/Umbraco.Core/Components/IUserComposer.cs @@ -6,7 +6,7 @@ /// /// All user composers require (compose after) all core composers. /// - [Require(typeof(ICoreComposer))] + [ComposeAfter(typeof(ICoreComposer))] public interface IUserComposer : IComposer { } } \ No newline at end of file diff --git a/src/Umbraco.Core/RuntimeState.cs b/src/Umbraco.Core/RuntimeState.cs index bb520a4571..df2ee44a7d 100644 --- a/src/Umbraco.Core/RuntimeState.cs +++ b/src/Umbraco.Core/RuntimeState.cs @@ -208,6 +208,10 @@ namespace Umbraco.Core throw new BootFailedException("Could not check the upgrade state.", e); } + // if we already know we want to upgrade, exit here + if (Level == RuntimeLevel.Upgrade) + return; + if (noUpgrade) { // the database version matches the code & files version, all clear, can run diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 425adc0b44..347d9f50c8 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -168,8 +168,8 @@ - - + + diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs index 6836ca433c..903c53292c 100644 --- a/src/Umbraco.Tests/Components/ComponentTests.cs +++ b/src/Umbraco.Tests/Components/ComponentTests.cs @@ -307,7 +307,7 @@ namespace Umbraco.Tests.Components public class Composer1 : TestComposerBase { } - [Require(typeof(Composer4))] + [ComposeAfter(typeof(Composer4))] public class Composer2 : TestComposerBase, ICoreComposer { } @@ -352,19 +352,19 @@ namespace Umbraco.Tests.Components public class Composer9 : TestComposerBase, ITestComposer { } - [Require(typeof(ITestComposer))] + [ComposeAfter(typeof(ITestComposer))] public class Composer10 : TestComposerBase { } - [Require(typeof(ITestComposer), false)] + [ComposeAfter(typeof(ITestComposer), false)] public class Composer11 : TestComposerBase { } - [Require(typeof(Composer4), true)] + [ComposeAfter(typeof(Composer4), true)] public class Composer12 : TestComposerBase, ICoreComposer { } - [RequiredBy(typeof(Composer1))] + [ComposeBefore(typeof(Composer1))] public class Composer13 : TestComposerBase { } @@ -375,14 +375,14 @@ namespace Umbraco.Tests.Components public class Composer20 : TestComposerBase { } - [RequiredBy(typeof(Composer20))] + [ComposeBefore(typeof(Composer20))] public class Composer21 : TestComposerBase { } public class Composer22 : TestComposerBase { } - [Require(typeof(Composer22))] + [ComposeAfter(typeof(Composer22))] public interface IComposer23 : IComposer { } @@ -390,7 +390,7 @@ namespace Umbraco.Tests.Components { } // should insert itself between 22 and anything i23 - [RequiredBy(typeof(IComposer23))] + [ComposeBefore(typeof(IComposer23))] //[RequireComponent(typeof(Component22))] - not needed, implement i23 public class Composer25 : TestComposerBase, IComposer23 { } diff --git a/src/Umbraco.Web/Cache/DistributedCacheBinderComposer.cs b/src/Umbraco.Web/Cache/DistributedCacheBinderComposer.cs index 87b181c2d0..80b673434e 100644 --- a/src/Umbraco.Web/Cache/DistributedCacheBinderComposer.cs +++ b/src/Umbraco.Web/Cache/DistributedCacheBinderComposer.cs @@ -8,7 +8,7 @@ namespace Umbraco.Web.Cache /// Installs listeners on service events in order to refresh our caches. /// [RuntimeLevel(MinLevel = RuntimeLevel.Run)] - [RequiredBy(typeof(ICoreComposer))] // runs before every other IUmbracoCoreComponent! + [ComposeBefore(typeof(ICoreComposer))] // runs before every other IUmbracoCoreComponent! public sealed class DistributedCacheBinderComposer : ICoreComposer { public void Compose(Composition composition) diff --git a/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs b/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs index 68199fa873..e31d31608e 100644 --- a/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs +++ b/src/Umbraco.Web/Components/DatabaseServerRegistrarAndMessengerComponent.cs @@ -35,7 +35,7 @@ namespace Umbraco.Web.Components // during Initialize / Startup, we end up checking Examine, which needs to be initialized beforehand // todo - should not be a strong dependency on "examine" but on an "indexing component" - [Require(typeof(ExamineComposer))] + [ComposeAfter(typeof(ExamineComposer))] public sealed class DatabaseServerRegistrarAndMessengerComposer : ICoreComposer { diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs index 66357cb435..3e3f45b2a4 100644 --- a/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs +++ b/src/Umbraco.Web/Runtime/WebRuntimeComposer.cs @@ -35,7 +35,7 @@ using Current = Umbraco.Web.Composing.Current; namespace Umbraco.Web.Runtime { - [Require(typeof(CoreRuntimeComposer))] + [ComposeAfter(typeof(CoreRuntimeComposer))] public sealed class WebRuntimeComposer : IRuntimeComposer { public void Compose(Composition composition)