Skip to content

Commit

Permalink
+ (CMS) Fix issue where WebsiteLavaTemplateCache returns an error and…
Browse files Browse the repository at this point in the history
… cannot be cleared. (Fixes SparkDevNetwork#5250)
  • Loading branch information
courtneycooksey committed Jan 23, 2023
1 parent 073a612 commit 335140e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Rock/Web/Cache/RockCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ public static List<CacheItemStatistics> GetAllStatistics()
/// <returns></returns>
public static CacheItemStatistics GetStatisticsForType( Type cacheType )
{
var cacheStats = new CacheItemStatistics( string.Empty );
var cacheStats = new CacheItemStatistics( string.Empty, string.Empty );
if ( _allManagers == null )
{
return cacheStats;
Expand All @@ -669,7 +669,7 @@ public static CacheItemStatistics GetStatisticsForType( Type cacheType )
/// <returns></returns>
public static CacheItemStatistics GetStatForSystemType( string cacheTypeName )
{
var cacheStats = new CacheItemStatistics( string.Empty );
var cacheStats = new CacheItemStatistics( string.Empty, string.Empty );
if ( _allManagers == null )
{
return cacheStats;
Expand Down Expand Up @@ -700,7 +700,7 @@ public static CacheItemStatistics GetStatisticsForType( string cacheTypeName )
{
if ( cacheTypeName.Contains( "Cache" ) )
{
return GetStatisticsForType( Type.GetType( $"Rock.Web.Cache.{cacheTypeName},Rock" ) );
return GetStatisticsForType( Type.GetType( cacheTypeName ) );
}

return GetStatForSystemType( cacheTypeName );
Expand Down
16 changes: 14 additions & 2 deletions Rock/Web/Cache/RockCacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,14 @@ public CacheItemStatistics GetStatistics()
var type = typeof( T );

string name = type.Name;
string fullname = type.FullName;
if ( type.IsGenericType && type.GenericTypeArguments[0] != null )
{
name = type.GenericTypeArguments[0].ToString();
fullname = type.GenericTypeArguments[0].ToString();
}

var cacheStatistics = new CacheItemStatistics( name );
var cacheStatistics = new CacheItemStatistics( name, fullname );

foreach ( var handle in CacheManager.CacheHandles )
{
Expand Down Expand Up @@ -440,6 +442,14 @@ public class CacheItemStatistics
/// </value>
public string Name { get; set; }

/// <summary>
/// Gets or sets the full name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string FullName { get; set; }

/// <summary>
/// Gets or sets the handle stats.
/// </summary>
Expand All @@ -452,9 +462,11 @@ public class CacheItemStatistics
/// Initializes a new instance of the <see cref="CacheItemStatistics"/> class.
/// </summary>
/// <param name="name">The name.</param>
public CacheItemStatistics( string name )
/// <param name="fullname">The full name.</param>
public CacheItemStatistics( string name, string fullname )
{
Name = name;
FullName = fullname;
}
}

Expand Down
10 changes: 5 additions & 5 deletions RockWeb/Blocks/Cms/CacheManager.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ protected void PopulateDdlCacheTypes()
var cacheStats = RockCache.GetAllStatistics();
foreach ( CacheItemStatistics cacheItemStat in cacheStats.OrderBy( s => s.Name ) )
{
ddlCacheTypes.Items.Add( new ListItem( cacheItemStat.Name, cacheItemStat.Name ) );
ddlCacheTypes.Items.Add( new ListItem( cacheItemStat.Name, cacheItemStat.FullName ) );
}
}

Expand Down Expand Up @@ -544,7 +544,7 @@ protected void ddlCacheTypes_SelectedIndexChanged( object sender, EventArgs e )
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected void rcbEnableStatistics_CheckedChanged(object sender, EventArgs e)
protected void rcbEnableStatistics_CheckedChanged( object sender, EventArgs e )
{
// Save updated value.
SystemSettings.SetValueToWebConfig( Rock.SystemKey.SystemSetting.CACHE_MANAGER_ENABLE_STATISTICS, rcbEnableStatistics.Checked.ToString() );
Expand Down Expand Up @@ -582,7 +582,7 @@ protected void dlgAddTag_SaveClick( object sender, EventArgs e )
private bool IsValid()
{
// Don't need to check for an edited tag as only the description is being changed.
if(hfTagId.Value.IsNotNullOrWhiteSpace() )
if ( hfTagId.Value.IsNotNullOrWhiteSpace() )
{
return true;
}
Expand Down Expand Up @@ -615,7 +615,7 @@ private bool IsValid()
/// </summary>
private void SaveTag()
{
if (hfTagId.Value == string.Empty)
if ( hfTagId.Value == string.Empty )
{
SaveNewTag();
}
Expand Down Expand Up @@ -657,7 +657,7 @@ private void SaveNewTag()
/// Updates and existing tag.
/// </summary>
/// <param name="cacheTagId">The Id of the tag.</param>
private void UpdateExistingTag(int cacheTagId )
private void UpdateExistingTag( int cacheTagId )
{
using ( var rockContext = new RockContext() )
{
Expand Down

0 comments on commit 335140e

Please sign in to comment.