Skip to content

Introduce IHostSettings to replace Host class#6538

Merged
david-poindexter merged 15 commits intodnnsoftware:developfrom
bdukes:host-settings
May 25, 2025
Merged

Introduce IHostSettings to replace Host class#6538
david-poindexter merged 15 commits intodnnsoftware:developfrom
bdukes:host-settings

Conversation

@bdukes
Copy link
Copy Markdown
Contributor

@bdukes bdukes commented May 2, 2025

Summary

In order to resolve usages of the deprecated HostController.Instance in DotNetNuke.Entities.Host.Host, this PR introduces DotNetNuke.Abstractions.Application.IHostSettings and its default implementation DotNetNuke.Entities.Host.HostSettings. This included creating a copy of the PerformanceSettings and SchedulerMode enums inside DotNetNuke.Abstractions, as well as extracting IFileExtensionAllowList from the FileExtensionWhitelist class.

IHostSettings differs from the old Host class in a few ways.

  1. All of the SMTP properties take a portalId parameter, rather than implicitly using the current portal context.
  2. Some of the return types are changed from int to TimeSpan to make date math easier and less error prone.
  3. Casing has been normalized (e.g. Guid instead of GUID, HostPortalId instead of HostPortalID)

@bdukes bdukes added this to the 10.0.2 milestone May 2, 2025
Copy link
Copy Markdown
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted a few questions...

@bdukes bdukes force-pushed the host-settings branch 3 times, most recently from a794088 to 6a18504 Compare May 5, 2025 16:57
@bdukes
Copy link
Copy Markdown
Contributor Author

bdukes commented May 5, 2025

I've pushed resolutions to all of your questions @valadas

Copy link
Copy Markdown
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cought 2 more little fallbacks missing and one more question, but looks great!

@bdukes bdukes force-pushed the host-settings branch 2 times, most recently from eb5868d to 4cdb886 Compare May 6, 2025 13:05
@bdukes bdukes requested a review from valadas May 6, 2025 15:28
Copy link
Copy Markdown
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing sticks out from the code however when I run DNN from this CI build I get the following error in Pages and Theme (persona bar modules)

2025-05-06 13:29:37.491-04:00 [DanielValadasPC][D:6][T:35][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.NullReferenceException: Object reference not set to an instance of an object.
   at DotNetNuke.UI.Skins.SkinController.CanDeleteSkin(IHostSettings hostSettings, String folderPath, String portalHomeDirMapPath)
   at Dnn.PersonaBar.Themes.Components.ThemesController.GetThemes(ThemeType type, String strRoot)
   at Dnn.PersonaBar.Themes.Components.ThemesController.GetLayouts(PortalSettings portalSettings, ThemeLevel level)
   at Dnn.PersonaBar.Themes.Components.ThemesController.GetThemeFile(PortalSettings portalSettings, String filePath, ThemeType type)
   at Dnn.PersonaBar.Pages.Components.Converters.ConvertToPageSettings[T](TabInfo tab)
   at Dnn.PersonaBar.Pages.Components.PagesControllerImpl.GetPageSettings(Int32 pageId, PortalSettings requestPortalSettings)
   at Dnn.PersonaBar.Pages.Services.PagesController.GetPageDetails(Int32 pageId)
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_0.<GetExecutor>b__2(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__17`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__17`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()

@bdukes
Copy link
Copy Markdown
Contributor Author

bdukes commented May 6, 2025

I found the issue (a missed hostSettings ??= Globals.GetCurrentServiceProvider().GetRequiredService<IHostSettings>(); line), I've pushed a fixed version. Thanks for testing.

@valadas
Copy link
Copy Markdown
Contributor

valadas commented May 6, 2025

I found the issue (a missed hostSettings ??= Globals.GetCurrentServiceProvider().GetRequiredService<IHostSettings>(); line), I've pushed a fixed version. Thanks for testing.

You are welcome, thanks for doing lol...
I'll retest when CI is finished.

@valadas
Copy link
Copy Markdown
Contributor

valadas commented May 6, 2025

I found the issue (a missed hostSettings ??= Globals.GetCurrentServiceProvider().GetRequiredService<IHostSettings>(); line), I've pushed a fixed version. Thanks for testing.

Just retested, looks like it worked for the Pages module but not the Themes module

@valadas
Copy link
Copy Markdown
Contributor

valadas commented May 6, 2025

It may however be a different issue, I see nothing in the log4net logs and I get this in the browswer:
No service for type 'DotNetNuke.Services.Localization.ILocaleController' has been registered.

@valadas
Copy link
Copy Markdown
Contributor

valadas commented May 6, 2025

Also in the extensions module I get An error occurred when trying to create a controller of type 'ExtensionsController'. Make sure that the controller has a parameterless public constructor.

@bdukes
Copy link
Copy Markdown
Contributor Author

bdukes commented May 6, 2025

It may however be a different issue, I see nothing in the log4net logs and I get this in the browswer: No service for type 'DotNetNuke.Services.Localization.ILocaleController' has been registered.

I just pushed a fix for the Themes extension (which was trying to use ILocaleController via DI, but it wasn't registered).

@bdukes
Copy link
Copy Markdown
Contributor Author

bdukes commented May 6, 2025

Also in the extensions module I get An error occurred when trying to create a controller of type 'ExtensionsController'. Make sure that the controller has a parameterless public constructor.

I made a small change to ExtensionsController, but I'll need to look closer at this. It does have a parameterless public controller…

@bdukes
Copy link
Copy Markdown
Contributor Author

bdukes commented May 6, 2025

I've fixed ExtensionsController (IPortalAliasController needed to be added to the DI container)

Copy link
Copy Markdown
Contributor

@GerardSmit GerardSmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this PR and had some small feedback/questions 😊

Copy link
Copy Markdown
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 more small things

SadSorryGIF

@bdukes bdukes requested a review from valadas May 13, 2025 13:13
Copy link
Copy Markdown
Contributor

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing sticks out to me anymore, looks great! I tested a clean install and all the PB modules appear to be showing the right info. Nice!

Copy link
Copy Markdown
Contributor

@david-poindexter david-poindexter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@david-poindexter david-poindexter merged commit 4f20ac1 into dnnsoftware:develop May 25, 2025
3 checks passed
@david-poindexter david-poindexter deleted the host-settings branch May 25, 2025 05:26
@valadas valadas modified the milestones: 10.0.2, 10.1.0 Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants