Fixing modified method signature, using a magic string rather than using CustomErrorsMode (System.Web.Configuration)

This commit is contained in:
elitsa
2020-01-28 13:32:32 +01:00
parent 394377f20a
commit ca863fce8d
7 changed files with 28 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using Umbraco.Core.IO;
using Umbraco.Web.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -14,6 +14,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
protected ILocalizedTextService TextService { get; }
protected IIOHelper IOHelper { get; }
protected ILogger Logger { get; }
/// <summary>
/// Gets the config file path.
@@ -53,11 +54,12 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
get { return false; }
}
protected AbstractConfigCheck(ILocalizedTextService textService, IIOHelper ioHelper)
protected AbstractConfigCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger)
{
TextService = textService;
IOHelper = ioHelper;
_configurationService = new ConfigurationService(AbsoluteFilePath, XPath, textService);
Logger = logger;
_configurationService = new ConfigurationService(AbsoluteFilePath, XPath, textService, logger);
}
/// <summary>

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -9,8 +10,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Live Environment")]
public class CompilationDebugCheck : AbstractConfigCheck
{
public CompilationDebugCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
public CompilationDebugCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger)
: base(textService, ioHelper, logger)
{ }
public override string FilePath => "~/Web.config";

View File

@@ -3,7 +3,6 @@ using System.IO;
using System.Xml;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using Umbraco.Web.Composing;
namespace Umbraco.Web.HealthCheck.Checks.Config
{
@@ -14,15 +13,19 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
private readonly string _configFilePath;
private readonly string _xPath;
private readonly ILocalizedTextService _textService;
private readonly ILogger _logger;
/// <param name="configFilePath">The absolute file location of the configuration file</param>
/// <param name="xPath">The XPath to select the value</param>
/// <param name="textService"></param>
/// <param name="logger"></param>
/// <returns></returns>
public ConfigurationService(string configFilePath, string xPath, ILocalizedTextService textService)
public ConfigurationService(string configFilePath, string xPath, ILocalizedTextService textService, ILogger logger)
{
_configFilePath = configFilePath;
_xPath = xPath;
_textService = textService;
_logger = logger;
}
/// <summary>
@@ -58,7 +61,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
}
catch (Exception ex)
{
Current.Logger.Error<ConfigurationService>(ex, "Error trying to get configuration value");
_logger.Error<ConfigurationService>(ex, "Error trying to get configuration value");
return new ConfigurationServiceResult
{
Success = false,
@@ -104,7 +107,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
}
catch (Exception ex)
{
Current.Logger.Error<ConfigurationService>(ex, "Error trying to update configuration");
_logger.Error<ConfigurationService>(ex, "Error trying to update configuration");
return new ConfigurationServiceResult
{
Success = false,

View File

@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -11,8 +11,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Live Environment")]
public class CustomErrorsCheck : AbstractConfigCheck
{
public CustomErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
public CustomErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger)
: base(textService, ioHelper, logger)
{ }
public override string FilePath => "~/Web.config";
@@ -23,7 +23,7 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
{
new AcceptableConfiguration { IsRecommended = true, Value = CustomErrorsMode.RemoteOnly.ToString() },
new AcceptableConfiguration { IsRecommended = true, Value = "RemoteOnly" },
new AcceptableConfiguration { IsRecommended = false, Value = "On" }
};

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -10,8 +11,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
Group = "Configuration")]
public class MacroErrorsCheck : AbstractConfigCheck
{
public MacroErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
public MacroErrorsCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger)
: base(textService, ioHelper, logger)
{ }
public override string FilePath => "~/Config/umbracoSettings.config";

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -11,8 +12,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
{
private const string DefaultFromEmail = "your@email.here";
public NotificationEmailCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
public NotificationEmailCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger)
: base(textService, ioHelper, logger)
{ }
public override string FilePath => "~/Config/umbracoSettings.config";

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
namespace Umbraco.Web.HealthCheck.Checks.Config
@@ -10,8 +11,8 @@ namespace Umbraco.Web.HealthCheck.Checks.Config
public class TraceCheck : AbstractConfigCheck
{
public TraceCheck(ILocalizedTextService textService, IIOHelper ioHelper)
: base(textService, ioHelper)
public TraceCheck(ILocalizedTextService textService, IIOHelper ioHelper, ILogger logger)
: base(textService, ioHelper, logger)
{ }
public override string FilePath => "~/Web.config";