Fixing blueprint element caching bug.

This fixes the issue where blueprint elements were still available even after deleting them.
The fix is to evict the cached element descriptors when a blueprint element is deleted.
This commit is contained in:
Sipke Schoorstra
2014-12-14 19:46:16 +01:00
parent 1565e8d48f
commit 829bfb094a
2 changed files with 7 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Orchard.Caching;
using Orchard.Data;
using Orchard.Layouts.Framework.Elements;
using Orchard.Layouts.Models;
@@ -7,8 +8,11 @@ using Orchard.Layouts.Models;
namespace Orchard.Layouts.Services {
public class ElementBlueprintService : IElementBlueprintService {
private readonly IRepository<ElementBlueprint> _blueprintRepository;
public ElementBlueprintService(IRepository<ElementBlueprint> blueprintRepository) {
private readonly ISignals _signals;
public ElementBlueprintService(IRepository<ElementBlueprint> blueprintRepository, ISignals signals) {
_blueprintRepository = blueprintRepository;
_signals = signals;
}
public ElementBlueprint GetBlueprint(int id) {
@@ -21,6 +25,7 @@ namespace Orchard.Layouts.Services {
public void DeleteBlueprint(ElementBlueprint blueprint) {
_blueprintRepository.Delete(blueprint);
_signals.Trigger(Signals.ElementDescriptors);
}
public int DeleteBlueprints(IEnumerable<int> ids) {

View File

@@ -72,6 +72,7 @@ namespace Orchard.Layouts.Services {
descriptor.Elements.Add(element);
}
acquireContext.Monitor(_signals.When(Signals.ElementDescriptors));
return categoryDescriptorDictionary.Values.OrderBy(x => x.Position);
});
}