Skip to content

Commit

Permalink
Merge pull request #5632 from dnnsoftware/release/9.11.2
Browse files Browse the repository at this point in the history
Merge `release/9.11.2` into `master` for release v9.11.2
  • Loading branch information
valadas authored Apr 17, 2023
2 parents d2f44d2 + 0c4f50b commit e51caac
Show file tree
Hide file tree
Showing 96 changed files with 5,392 additions and 4,426 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ Provide any additional context that may be helpful in understanding and/or resol
Please add X in at least one of the boxes as appropriate. In order for an issue to be accepted, a developer needs to be able to reproduce the issue on a currently supported version. If you are looking for a workaround for an issue with an older version, please visit the forums at https://dnncommunity.org/forums
-->
* [ ] 10.00.00 alpha build
* [ ] 09.11.01 release candidate
* [ ] 09.11.00 latest supported release
* [ ] 09.11.01 latest supported release

## Affected browser
<!--
Expand Down
785 changes: 0 additions & 785 deletions .yarn/releases/yarn-3.2.0.cjs

This file was deleted.

873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.2.0.cjs
yarnPath: .yarn/releases/yarn-3.4.1.cjs
1 change: 1 addition & 0 deletions Build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageReference Include="Cake.XdtTransform" Version="2.0.0" />
<PackageReference Include="Cake.Yarn" Version="0.4.8" />
<PackageReference Include="Dnn.CakeUtils" Version="2.0.2" />
<PackageReference Include="MSBuild.StructuredLogger" Version="2.1.787" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down
1 change: 0 additions & 1 deletion Build/Tasks/BuildNpmPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public sealed class BuildNpmPackages : FrostingTask<Context>
/// <inheritdoc/>
public override void Run(Context context)
{
Environment.SetEnvironmentVariable("NODE_OPTIONS", "--openssl-legacy-provider");
context.Yarn().Install(c => c
.WithArgument("--no-immutable")
.WithWorkingDirectory(context.Directory("./")));
Expand Down
1 change: 0 additions & 1 deletion Build/Tools/NuGet/DotNetNuke.Bundle.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<dependency id="DotNetNuke.Providers.FolderProviders" version="$version$" />
<dependency id="DotNetNuke.SiteExportImport" version="$version$" />
<dependency id="DotNetNuke.Web.Client" version="$version$" />
<dependency id="DotNetNuke.Web.Deprecated" version="$version$" />
<dependency id="DotNetNuke.Web.Mvc" version="$version$" />
<dependency id="DotNetNuke.Web" version="$version$" />
<dependency id="DotNetNuke.WebApi" version="$version$" />
Expand Down
5 changes: 5 additions & 0 deletions DNN Platform/Library/Data/DataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,11 @@ public virtual void RemoveUser(int userId, int portalId)
this.ExecuteNonQuery("RemoveUser", userId, this.GetNull(portalId));
}

public virtual void ReplaceServerOnSchedules(string oldServername, string newServerName)
{
this.ExecuteNonQuery("ReplaceServerOnSchedules", oldServername, newServerName);
}

public virtual void ResetTermsAgreement(int portalId)
{
this.ExecuteNonQuery("ResetTermsAgreement", portalId);
Expand Down
1 change: 1 addition & 0 deletions DNN Platform/Library/DotNetNuke.Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@
<Compile Include="Services\Social\Messaging\IUserPreferencesController.cs" />
<Compile Include="Services\Social\Messaging\UserPreference.cs" />
<Compile Include="Services\Social\Messaging\UserPreferencesController.cs" />
<Compile Include="Services\SystemHealth\WebServerMonitor.cs" />
<Compile Include="Services\Tokens\CacheLevel.cs" />
<Compile Include="Services\Tokens\HtmlTokenReplace.cs" />
<Compile Include="Services\Tokens\PropertyAccess\AntiForgeryTokenPropertyAccess.cs" />
Expand Down
69 changes: 48 additions & 21 deletions DNN Platform/Library/Entities/Host/ServerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace DotNetNuke.Entities.Host
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Web.Caching;

using DotNetNuke.Common;
Expand All @@ -15,6 +16,7 @@ namespace DotNetNuke.Entities.Host
using DotNetNuke.Framework;
using DotNetNuke.Instrumentation;
using DotNetNuke.Services.Log.EventLog;
using DotNetNuke.UI.WebControls;

public class ServerController
{
Expand Down Expand Up @@ -53,20 +55,33 @@ public static void DeleteServer(int serverID)

public static List<ServerInfo> GetEnabledServers()
{
var servers = new List<ServerInfo>();
var storedServers = GetServers();
if (storedServers != null)
{
foreach (ServerInfo server in storedServers)
{
if (server.Enabled)
{
servers.Add(server);
}
}
}

return servers;
return GetServers()?.Where(i => i.Enabled).ToList() ?? new List<ServerInfo>();
}

/// <summary>
/// Gets the servers, order by last activity date in descending order.
/// </summary>
/// <param name="lastMinutes">The number of recent minutes activity had to occur</param>
/// <returns>A list of servers with activity within the specified minutes</returns>
public static List<ServerInfo> GetEnabledServersWithActivity(int lastMinutes = 10)
{
return GetServersNoCache()
.Where(i => i.Enabled == true && DateTime.Now.Subtract(i.LastActivityDate).TotalMinutes <= lastMinutes)
.OrderByDescending(i => i.LastActivityDate)
.ToList();
}

/// <summary>
/// Gets the servers, that have no activtiy in the specified time frame.
/// </summary>
/// <param name="lastMinutes">The number of recent minutes activity had to occur</param>
/// <returns>A list of servers with no activity for the specified minutes. Defaults to 24 hours</returns>
public static List<ServerInfo> GetInActiveServers(int lastMinutes = 1440)
{
return GetServersNoCache()
.Where(i => DateTime.Now.Subtract(i.LastActivityDate).TotalMinutes > lastMinutes && i.ServerName != Environment.MachineName)
.OrderByDescending(i => i.LastActivityDate)
.ToList();
}

public static string GetExecutingServerName()
Expand Down Expand Up @@ -106,8 +121,9 @@ public static void UpdateServer(ServerInfo server)
}

public static void UpdateServerActivity(ServerInfo server)
{
var existServer = GetServers().FirstOrDefault(s => s.ServerName == server.ServerName && s.IISAppName == server.IISAppName);
{
var allServers = GetServers();
var existServer = allServers.FirstOrDefault(s => s.ServerName == server.ServerName && s.IISAppName == server.IISAppName);
var serverId = DataProvider.Instance().UpdateServerActivity(server.ServerName, server.IISAppName, server.CreatedDate, server.LastActivityDate, server.PingFailureCount, server.Enabled);

server.ServerID = serverId;
Expand All @@ -121,26 +137,37 @@ public static void UpdateServerActivity(ServerInfo server)
// try to detect the server unique id from url adapter.
server.UniqueId = existServer == null || string.IsNullOrEmpty(existServer.UniqueId) ? GetServerUniqueId() : existServer.UniqueId;

UpdateServer(server);
UpdateServer(server);
ClearCachedServers(); // Only clear the cache if we added a server
}
else
{
// Just update the existing item in the cache
existServer.LastActivityDate = server.LastActivityDate;
existServer.Enabled = server.Enabled;
DataCache.SetCache(ServerController.CacheKey, allServers);
}

// log the server info
var log = new LogInfo();
var log = new LogInfo();
log.AddProperty(existServer != null ? "Server Updated" : "Add New Server", server.ServerName);
log.AddProperty("IISAppName", server.IISAppName);
log.AddProperty("Last Activity Date", server.LastActivityDate.ToString());
log.LogTypeKey = existServer != null ? EventLogController.EventLogType.WEBSERVER_UPDATED.ToString()
: EventLogController.EventLogType.WEBSERVER_CREATED.ToString();
LogController.Instance.AddLog(log);

ClearCachedServers();
}

public static IServerWebRequestAdapter GetServerWebRequestAdapter()
{
var adapterConfig = HostController.Instance.GetString("WebServer_ServerRequestAdapter", DefaultUrlAdapter);
var adapterType = Reflection.CreateType(adapterConfig);
return Reflection.CreateInstance(adapterType) as IServerWebRequestAdapter;
}

private static List<ServerInfo> GetServersNoCache()
{
return CBO.FillCollection<ServerInfo>(DataProvider.GetServers());
}

private static object GetServersCallBack(CacheItemArgs cacheItemArgs)
Expand Down
7 changes: 7 additions & 0 deletions DNN Platform/Library/Services/Scheduling/DNNScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace DotNetNuke.Services.Scheduling

using DotNetNuke.Common.Utilities;
using DotNetNuke.ComponentModel;
using DotNetNuke.Entities.Host;
using Microsoft.VisualBasic;

public class DNNScheduler : SchedulingProvider
Expand Down Expand Up @@ -192,6 +193,12 @@ public override void RunEventSchedule(EventName eventName)
/// <inheritdoc/>
public override void RunScheduleItemNow(ScheduleItem scheduleItem, bool runNow)
{
// If the validation for the server failed, then the server was updated. The scheduled item will be picked up on the next check, so we can exit the request for this instance to run.
if (!Scheduler.CoreScheduler.ValidateServersAreActiveForScheduledItem(scheduleItem))
{
return;
}

// Remove item from queue
Scheduler.CoreScheduler.RemoveFromScheduleQueue(scheduleItem);
var scheduleHistoryItem = new ScheduleHistoryItem(scheduleItem) { NextStart = runNow ? DateTime.Now : (scheduleItem.ScheduleStartDate != Null.NullDate ? scheduleItem.ScheduleStartDate : DateTime.Now) };
Expand Down
43 changes: 42 additions & 1 deletion DNN Platform/Library/Services/Scheduling/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,46 @@ public static ScheduleHistoryItem AddScheduleHistory(ScheduleHistoryItem schedul
return scheduleHistoryItem;
}

/// <summary>
/// Checks the scheduled item if it has servers specified to run on. If it does, then it checks to see if the server is active.
/// </summary>
/// <param name="scheduleItem">The schedule to check</param>
/// <returns>True if nothing happens to the scheduled item. Returns false if the scheduled item was updated.</returns>
/// <remarks>
/// If the server specified is not active then the scheduled item will be assigned to the most recent active server.
/// This assumes that all schedules will run on a single server if none of the servers specified are active.
/// </remarks>
public static bool ValidateServersAreActiveForScheduledItem(ScheduleItem scheduleItem)
{
// If this scheduled items runs on all servers, continue.
if (string.IsNullOrEmpty(scheduleItem.Servers))
{
return true;
}

// Get the individual server names from the scheduled item
var servers = scheduleItem.Servers.ToLowerInvariant().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

// Get the enabled servers with recent activity.
var enabledServers = ServerController.GetEnabledServersWithActivity();

// Validate that any server in the scheduled item is in the enabled server list with activity in the last 10 minutes.
bool serverHasRecentActivity = enabledServers.Any(i => servers.Contains(i.ServerName.ToLowerInvariant()));

// If no servers in the scheduled item had recent activity, assign this scheduled item to the server with the most recent activity
if (!serverHasRecentActivity)
{
// Assign a new server to this task then run it
scheduleItem.Servers = $",{enabledServers.First().ServerName.ToLowerInvariant()},";

// Save the scheduled item back to the database.
SchedulingController.UpdateSchedule(scheduleItem);
return false;
}

return true;
}

/// <summary>Adds an item to the collection of schedule items in queue.</summary>
/// <param name="scheduleHistoryItem"></param>
/// <remarks>Thread Safe.</remarks>
Expand All @@ -119,7 +159,8 @@ public static void AddToScheduleQueue(ScheduleHistoryItem scheduleHistoryItem)
{
// Do a second check just in case
if (!ScheduleQueueContains(scheduleHistoryItem) &&
!IsInProgress(scheduleHistoryItem))
!IsInProgress(scheduleHistoryItem) &&
ValidateServersAreActiveForScheduledItem(scheduleHistoryItem))
{
// It is safe for this thread to read or write
// from the shared resource.
Expand Down
10 changes: 10 additions & 0 deletions DNN Platform/Library/Services/Scheduling/SchedulingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,15 @@ public static bool CanRunOnThisServer(string servers)

return false;
}

/// <summary>
/// Replaces the old server name, with the new server name on all schedules where the old server name was found.
/// </summary>
/// <param name="oldServer">The old server to replace</param>
/// <param name="newServer">The new server to use</param>
internal static void ReplaceServer(ServerInfo oldServer, ServerInfo newServer)
{
DataProvider.Instance().ReplaceServerOnSchedules(oldServer.ServerName, newServer.ServerName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace DotNetNuke.Services.Scheduling
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

using System.Linq;
using DotNetNuke.Common.Utilities;
using DotNetNuke.ComponentModel;
using DotNetNuke.Entities.Controllers;
Expand Down
3 changes: 2 additions & 1 deletion DNN Platform/Library/Services/Syndication/RssHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace DotNetNuke.Services.Syndication
using DotNetNuke.Services.Search.Entities;
using DotNetNuke.Services.Search.Internals;

/// <summary>An HTTP handler for serving an RSS feed.</summary>
public class RssHandler : SyndicationHandlerBase
{
/// <inheritdoc />
Expand Down Expand Up @@ -99,7 +100,7 @@ protected override void OnPreRender(EventArgs ea)
}

/// <summary>Creates an RSS Item.</summary>
/// <param name="searchResult"></param>
/// <param name="searchResult">The search result to convert to an RSS item.</param>
/// <returns>A new <see cref="GenericRssElement"/> instance.</returns>
private GenericRssElement GetRssItem(SearchResult searchResult)
{
Expand Down
Loading

0 comments on commit e51caac

Please sign in to comment.