diff --git a/src/Umbraco.Infrastructure/Cache/DatabaseServerMessengerNotificationHandler.cs b/src/Umbraco.Infrastructure/Cache/DatabaseServerMessengerNotificationHandler.cs
index e627284f8b..092b4c6b99 100644
--- a/src/Umbraco.Infrastructure/Cache/DatabaseServerMessengerNotificationHandler.cs
+++ b/src/Umbraco.Infrastructure/Cache/DatabaseServerMessengerNotificationHandler.cs
@@ -38,19 +38,19 @@ namespace Umbraco.Cms.Core.Cache
///
public void Handle(UmbracoApplicationStartingNotification notification)
{
+ if (_runtimeState.Level < RuntimeLevel.Run)
+ {
+ return;
+ }
+
if (_databaseFactory.CanConnect == false)
{
_logger.LogWarning("Cannot connect to the database, distributed calls will not be enabled for this server.");
- }
- else if (_runtimeState.Level != RuntimeLevel.Run)
- {
- _logger.LogWarning("Distributed calls are not available outside the Run runtime level");
- }
- else
- {
- // Sync on startup, this will run through the messenger's initialization sequence
- _messenger?.Sync();
+ return;
}
+
+ // Sync on startup, this will run through the messenger's initialization sequence
+ _messenger?.Sync();
}
///
diff --git a/src/Umbraco.Infrastructure/Examine/RebuildOnStartupHandler.cs b/src/Umbraco.Infrastructure/Examine/RebuildOnStartupHandler.cs
index 60f7478c3f..05b016dbb6 100644
--- a/src/Umbraco.Infrastructure/Examine/RebuildOnStartupHandler.cs
+++ b/src/Umbraco.Infrastructure/Examine/RebuildOnStartupHandler.cs
@@ -1,7 +1,9 @@
using System;
using System.Threading;
+using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
+using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;
namespace Umbraco.Cms.Infrastructure.Examine
@@ -17,6 +19,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
{
private readonly ISyncBootStateAccessor _syncBootStateAccessor;
private readonly ExamineIndexRebuilder _backgroundIndexRebuilder;
+ private readonly IRuntimeState _runtimeState;
// These must be static because notification handlers are transient.
// this does unfortunatley mean that one RebuildOnStartupHandler instance
@@ -30,10 +33,12 @@ namespace Umbraco.Cms.Infrastructure.Examine
public RebuildOnStartupHandler(
ISyncBootStateAccessor syncBootStateAccessor,
- ExamineIndexRebuilder backgroundIndexRebuilder)
+ ExamineIndexRebuilder backgroundIndexRebuilder,
+ IRuntimeState runtimeState)
{
_syncBootStateAccessor = syncBootStateAccessor;
_backgroundIndexRebuilder = backgroundIndexRebuilder;
+ _runtimeState = runtimeState;
}
///
@@ -41,7 +46,13 @@ namespace Umbraco.Cms.Infrastructure.Examine
///
///
public void Handle(UmbracoRequestBeginNotification notification)
- => LazyInitializer.EnsureInitialized(
+ {
+ if (_runtimeState.Level < RuntimeLevel.Run)
+ {
+ return;
+ }
+
+ LazyInitializer.EnsureInitialized(
ref _isReady,
ref _isReadSet,
ref _isReadyLock,
@@ -56,5 +67,6 @@ namespace Umbraco.Cms.Infrastructure.Examine
return true;
});
+ }
}
}
diff --git a/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
index 944195cb82..10d6fa2278 100644
--- a/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs
@@ -112,27 +112,6 @@ namespace Umbraco.Cms.Infrastructure.Persistence
Configure(settings.ConnectionString, settings.ProviderName);
}
- ///
- /// Initializes a new instance of the .
- ///
- /// Used in tests.
- public UmbracoDatabaseFactory(ILogger logger, ILoggerFactory loggerFactory, string connectionString, string providerName, Lazy mappers, IDbProviderFactoryCreator dbProviderFactoryCreator, DatabaseSchemaCreatorFactory databaseSchemaCreatorFactory)
- {
- _mappers = mappers ?? throw new ArgumentNullException(nameof(mappers));
- _logger = logger ?? throw new ArgumentNullException(nameof(logger));
- _loggerFactory = loggerFactory;
- _dbProviderFactoryCreator = dbProviderFactoryCreator ?? throw new ArgumentNullException(nameof(dbProviderFactoryCreator));
- _databaseSchemaCreatorFactory = databaseSchemaCreatorFactory ?? throw new ArgumentNullException(nameof(databaseSchemaCreatorFactory));
-
- if (string.IsNullOrWhiteSpace(connectionString) || string.IsNullOrWhiteSpace(providerName))
- {
- logger.LogDebug("Missing connection string or provider name, defer configuration.");
- return; // not configured
- }
-
- Configure(connectionString, providerName);
- }
-
#endregion
///