-
Couldn't load subscription status.
- Fork 2.8k
Closed
Description
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
8.18.9
Bug summary
The EventState is lost between the SavingDictionaryItem and SavedDictionaryItem events.
This does not happen when the item is first created, it only happens when attempting to save after that.
Tried it in an Umbraco 12 install, using notifications, and there it worked correctly.
Specifics
No response
Steps to reproduce
- Set up a new Umbraco 8 install (default installation, no content required)
- Create a new C# file in the project and add the following content:
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
namespace Umbraco8.Web
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class TestComposer : ComponentComposer<TestComponent> { }
public class TestComponent : IComponent
{
public void Initialize()
{
LocalizationService.SavingDictionaryItem += SavingDictionaryItem;
LocalizationService.SavedDictionaryItem += SavedDictionaryItem;
}
private static void SavingDictionaryItem(ILocalizationService sender, SaveEventArgs<IDictionaryItem> e)
{
e.EventState["key"] = "This is a test!";
}
private static void SavedDictionaryItem(ILocalizationService sender, SaveEventArgs<IDictionaryItem> e)
{
var test = e.EventState["key"];
}
public void Terminate()
{
LocalizationService.SavingDictionaryItem -= SavingDictionaryItem;
LocalizationService.SavedDictionaryItem -= SavedDictionaryItem;
}
}
}- Boot up the website
- Create a new dictionary item (this one works as expected!)
- Save the same dictionary item (again) 💥
Verify that you get aSystem.Collections.Generic.KeyNotFoundException: 'The given key was not present in the dictionary.'due to theEventStatebeing empty.
Expected result / actual result
Expected: The EventState is kept between the SavingDictionaryItem and SavedDictionaryItem
Actual: EventState is empty on SavedDictionaryItem