From f3d9b4a9f3705aa64a1f552b38db332b4ff40fdf Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 23 Jul 2015 12:28:17 +0200 Subject: [PATCH] Fixes BatchedDatabaseServerMessenger - it implements IApplicationEventHandler to control it's bootup process which ensures it doesn't attempt to boot or bind to events if the app is not configured or installing. This was preventing upgrading to 7.3 --- .../BatchedDatabaseServerMessenger.cs | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs b/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs index 4eeb5c84f9..fee56fd209 100644 --- a/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs +++ b/src/Umbraco.Web/BatchedDatabaseServerMessenger.cs @@ -18,31 +18,45 @@ namespace Umbraco.Web /// /// This binds to appropriate umbraco events in order to trigger the Boot(), Sync() & FlushBatch() calls /// - public class BatchedDatabaseServerMessenger : Core.Sync.DatabaseServerMessenger + public class BatchedDatabaseServerMessenger : DatabaseServerMessenger, IApplicationEventHandler { public BatchedDatabaseServerMessenger(ApplicationContext appContext, bool enableDistCalls, DatabaseServerMessengerOptions options) : base(appContext, enableDistCalls, options) - { - UmbracoApplicationBase.ApplicationStarted += Application_Started; - UmbracoModule.EndRequest += UmbracoModule_EndRequest; - UmbracoModule.RouteAttempt += UmbracoModule_RouteAttempt; + { } - private void Application_Started(object sender, EventArgs eventArgs) - { - if (ApplicationContext.IsConfigured == false - || ApplicationContext.DatabaseContext.IsDatabaseConfigured == false - || ApplicationContext.DatabaseContext.CanConnect == false) - { + #region Application Event Handler implementation - LogHelper.Warn("The app is not configured or cannot connect to the database, this server cannot be initialized with " - + typeof (BatchedDatabaseServerMessenger) + ", distributed calls will not be enabled for this server"); + public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) + { + } + + public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) + { + } + + /// + /// Bootup is completed, this will not execute if the application is not configured + /// + /// + /// + public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) + { + UmbracoModule.EndRequest += UmbracoModule_EndRequest; + UmbracoModule.RouteAttempt += UmbracoModule_RouteAttempt; + + if (applicationContext.DatabaseContext.IsDatabaseConfigured == false || applicationContext.DatabaseContext.CanConnect == false) + { + applicationContext.ProfilingLogger.Logger.Warn( + "The app cannot connect to the database, this server cannot be initialized with " + + typeof(BatchedDatabaseServerMessenger) + ", distributed calls will not be enabled for this server"); } else { - Boot(); + Boot(); } } + #endregion private void UmbracoModule_RouteAttempt(object sender, RoutableAttemptEventArgs e) { @@ -137,5 +151,7 @@ namespace Umbraco.Web batch.Add(new RefreshInstructionEnvelope(servers, refresher, RefreshInstruction.GetInstructions(refresher, messageType, ids, idType, json))); } + + } } \ No newline at end of file