Fixes moving event dispatching in content service which prohibited you from moving anything
This commit is contained in:
@@ -1510,7 +1510,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
var moveEventInfo = new MoveEventInfo<IContent>(content, content.Path, parentId);
|
||||
var moveEventArgs = new MoveEventArgs<IContent>(moveEventInfo);
|
||||
if (scope.Events.DispatchCancelable(Moving, this, moveEventArgs))
|
||||
if (scope.Events.DispatchCancelable(Moving, this, moveEventArgs, nameof(Moving)))
|
||||
{
|
||||
scope.Complete();
|
||||
return; // causes rollback
|
||||
@@ -1541,7 +1541,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
moveEventArgs.MoveInfoCollection = moveInfo;
|
||||
moveEventArgs.CanCancel = false;
|
||||
scope.Events.Dispatch(Moved, this, moveEventArgs);
|
||||
scope.Events.Dispatch(Moved, this, moveEventArgs, nameof(Moved));
|
||||
Audit(AuditType.Move, "Move Content performed by user", userId, content.Id);
|
||||
|
||||
scope.Complete();
|
||||
@@ -2249,7 +2249,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
// but... UnPublishing event makes no sense (not going to cancel?) and no need to save
|
||||
// just raise the event
|
||||
if (content.Trashed == false && content.Published)
|
||||
scope.Events.Dispatch(UnPublished, this, new PublishEventArgs<IContent>(content, false, false), "UnPublished");
|
||||
scope.Events.Dispatch(UnPublished, this, new PublishEventArgs<IContent>(content, false, false), nameof(UnPublished));
|
||||
|
||||
// if current content has children, move them to trash
|
||||
var c = content;
|
||||
@@ -2272,7 +2272,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
.Select(x => new MoveEventInfo<IContent>(x.Item1, x.Item2, x.Item1.ParentId))
|
||||
.ToArray();
|
||||
if (moveInfos.Length > 0)
|
||||
scope.Events.Dispatch(Trashed, this, new MoveEventArgs<IContent>(false, moveInfos), "Trashed");
|
||||
scope.Events.Dispatch(Trashed, this, new MoveEventArgs<IContent>(false, moveInfos), nameof(Trashed));
|
||||
scope.Events.Dispatch(TreeChanged, this, changes.ToEventArgs());
|
||||
|
||||
Audit(AuditType.Delete, $"Delete Content of Type {string.Join(",", contentTypeIdsA)} performed by user", userId, Constants.System.Root);
|
||||
|
||||
@@ -24,7 +24,8 @@ using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
/// <summary>
|
||||
@@ -58,6 +59,32 @@ namespace Umbraco.Tests.Services
|
||||
// fixme - do it differently
|
||||
Container.Register(factory => factory.GetInstance<ServiceContext>().TextService);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to list out all ambiguous events that will require dispatching with a name
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void List_Ambiguous_Events()
|
||||
{
|
||||
var events = ServiceContext.ContentService.GetType().GetEvents(BindingFlags.Static | BindingFlags.Public);
|
||||
var typedEventHandler = typeof(TypedEventHandler<,>);
|
||||
foreach(var e in events)
|
||||
{
|
||||
//only continue if this is a TypedEventHandler
|
||||
if (!e.EventHandlerType.IsGenericType) continue;
|
||||
var typeDef = e.EventHandlerType.GetGenericTypeDefinition();
|
||||
if (typedEventHandler != typeDef) continue;
|
||||
|
||||
//get the event arg type
|
||||
var eventArgType = e.EventHandlerType.GenericTypeArguments[1];
|
||||
|
||||
var found = EventNameExtractor.FindEvent(typeof(ContentService), eventArgType, EventNameExtractor.MatchIngNames);
|
||||
if (!found.Success && found.Result.Error == EventNameExtractorError.Ambiguous)
|
||||
{
|
||||
Console.WriteLine($"Ambiguous event, source: {typeof(ContentService)}, args: {eventArgType}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Create_Blueprint()
|
||||
|
||||
Reference in New Issue
Block a user