diff --git a/src/Umbraco.Web/HealthCheck/Checks/Config/AbstractConfigCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Config/AbstractConfigCheck.cs index 001bd4e3e8..2cec88d616 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Config/AbstractConfigCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Config/AbstractConfigCheck.cs @@ -43,6 +43,14 @@ namespace Umbraco.Web.HealthCheck.Checks.Config /// public abstract ValueComparisonType ValueComparisonType { get; } + /// + /// Gets the flag indicating if the check is considered successful if the config value is missing (defaults to false - an error - if missing) + /// + public virtual bool ValidIfConfigMissing + { + get { return false; } + } + protected AbstractConfigCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext) { _textService = healthCheckContext.ApplicationContext.Services.TextService; @@ -132,11 +140,18 @@ namespace Umbraco.Web.HealthCheck.Checks.Config public override IEnumerable GetStatus() { + var successMessage = string.Format(CheckSuccessMessage, FileName, XPath, Values, CurrentValue); + var configValue = _configurationService.GetConfigurationValue(); if (configValue.Success == false) { - var message = configValue.Result; - return new[] { new HealthCheckStatus(message) { ResultType = StatusResultType.Error } }; + if (ValidIfConfigMissing) + { + return new[] { new HealthCheckStatus(successMessage) { ResultType = StatusResultType.Success } }; + } + + var errorMessage = configValue.Result; + return new[] { new HealthCheckStatus(errorMessage) { ResultType = StatusResultType.Error } }; } CurrentValue = configValue.Result; @@ -144,8 +159,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config var valueFound = Values.Any(value => string.Equals(CurrentValue, value.Value, StringComparison.InvariantCultureIgnoreCase)); if (ValueComparisonType == ValueComparisonType.ShouldEqual && valueFound || ValueComparisonType == ValueComparisonType.ShouldNotEqual && valueFound == false) { - var message = string.Format(CheckSuccessMessage, FileName, XPath, Values, CurrentValue); - return new[] { new HealthCheckStatus(message) { ResultType = StatusResultType.Success } }; + return new[] { new HealthCheckStatus(successMessage) { ResultType = StatusResultType.Success } }; } // Declare the action for rectifying the config value diff --git a/src/Umbraco.Web/HealthCheck/Checks/Config/CompilationDebugCheck.cs b/src/Umbraco.Web/HealthCheck/Checks/Config/CompilationDebugCheck.cs index 989046b464..6612b77b26 100644 --- a/src/Umbraco.Web/HealthCheck/Checks/Config/CompilationDebugCheck.cs +++ b/src/Umbraco.Web/HealthCheck/Checks/Config/CompilationDebugCheck.cs @@ -30,6 +30,11 @@ namespace Umbraco.Web.HealthCheck.Checks.Config get { return ValueComparisonType.ShouldEqual; } } + public override bool ValidIfConfigMissing + { + get { return true; } + } + public override IEnumerable Values { get