Skip to content

Commit

Permalink
Correct the portalId by GetEffectivePortalId which is pointing to cor… (
Browse files Browse the repository at this point in the history
#2285)

* Correct the portalId by GetEffectivePortalId which is pointing to correct portal whether SiteGroup exist or not

* Changes for optimization to clear User cache
  • Loading branch information
Mohtisham authored and tpluscode committed Sep 10, 2018
1 parent 7946f53 commit d61f0f9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
7 changes: 6 additions & 1 deletion DNN Platform/Library/Common/Utilities/DataCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ public static void ClearUserCache(int PortalId, string username)
RemoveCache(String.Format(UserProfileCacheKey, PortalId, username));
}

public static void ClearPortalUserCountCache(int portalID)
{
CachingProvider.Instance().Remove(string.Format(DataCache.PortalUserCountCacheKey, portalID));
}

public static void ClearUserPersonalizationCache(int portalId, int userId)
{
RemoveCache(String.Format(UserPersonalizationCacheKey, portalId, userId));
Expand Down Expand Up @@ -761,6 +766,6 @@ public static void SetCache(string CacheKey, object objObject, DNNCacheDependenc
}
CachingProvider.Instance().Insert(GetDnnCacheKey(CacheKey), objObject, objDependency, AbsoluteExpiration, SlidingExpiration, Priority, OnRemoveCallback);
}
}
}
}
}
8 changes: 4 additions & 4 deletions DNN Platform/Library/Entities/Users/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,8 @@ public static bool DeleteUser(ref UserInfo user, bool notify, bool deleteAdmin)
//send email notification to portal administrator that the user was removed from the portal
SendDeleteEmailNotifications(user, portalSettings);
}

CachingProvider.Instance().Remove(string.Format(DataCache.PortalUserCountCacheKey, user.PortalID));
DataCache.ClearPortalUserCountCache(user.PortalID);
DataCache.ClearUserCache(user.PortalID, user.Username);

//also clear current portal's cache if the user is a host user
Expand Down Expand Up @@ -1885,8 +1885,8 @@ public static bool RestoreUser(ref UserInfo user)
//Log event
EventLogController.Instance.AddLog("Username", user.Username, portalSettings, user.UserID, EventLogController.EventLogType.USER_RESTORED);

DataCache.ClearPortalCache(portalId, false);
DataCache.ClearUserCache(portalId, user.Username);
DataCache.ClearPortalUserCountCache(user.PortalID);
DataCache.ClearUserCache(user.PortalID, user.Username);
}

//Reset PortalId
Expand Down
4 changes: 2 additions & 2 deletions Website/DesktopModules/Admin/Security/Register.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ private void CreateUser()
User.Membership.Approved = PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration;
var user = User;
CreateStatus = UserController.CreateUser(ref user);

CachingProvider.Instance().Remove(string.Format(DataCache.PortalUserCountCacheKey, PortalId));
DataCache.ClearPortalUserCountCache(PortalId);

try
{
Expand Down
6 changes: 3 additions & 3 deletions Website/DesktopModules/Admin/Security/User.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ private void cmdUpdate_Click(Object sender, EventArgs e)
{
if (IsValid)
{
CreateUser();
CachingProvider.Instance().Remove(string.Format(DataCache.PortalUserCountCacheKey, PortalId));
CreateUser();
DataCache.ClearPortalUserCountCache(PortalId);
}
}
else
Expand All @@ -588,7 +588,7 @@ private void cmdUpdate_Click(Object sender, EventArgs e)
if (User.UserID == PortalSettings.AdministratorId)
{
//Clear the Portal Cache
DataCache.ClearPortalCache(UserPortalID, true);
DataCache.ClearPortalUserCountCache(UserPortalID);
}
try
{
Expand Down

0 comments on commit d61f0f9

Please sign in to comment.