Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Braydie 148 posts 346 karma points
    Jun 18, 2013 @ 13:14
    Braydie
    0

    Cancelling deletion with Event Handlers in 6.1.1

    I have an event handler that I was using in 4.7.2 to cancel the deletion of a Document, but this is no longer working in the way in which I would expect in 6.1.1.

    When this event hanlder fires, the page is not deleted which is fine, but the message that is displayed to the content editor is "Error Handling Action - No node exists with the id '0'", and I get an error thrown by /umbraco/webservices/legacyAjaxCalls.asmx/Delete

    My event handler looks something like this:

    public PreventContentDeletionEventSubscriber()
            {   
                    Document.BeforeMoveToTrash += new Document.MoveToTrashEventHandler(Document_BeforeMoveToTrash);         
            }   
    
      protected virtual void Document_BeforeMoveToTrash(Document Sender, umbraco.cms.businesslogic.MoveToTrashEventArgs e)
            {
                if (IsRelated(Sender.Id))
                {
                    e.Cancel = true;
                }
            }

    I have had a couple of my other event handlers require changes based on upgrading to 6.1.1 so I'm hopeful that this is another instance where I need to change my event handler.

    Has anyone else come across this?

    Thanks!

  • Braydie 148 posts 346 karma points
    Jun 18, 2013 @ 17:31
    Braydie
    0

    A little digging around and it appears that this has been an issue in 4.9.0 so I wonder if this issue and the one I'm experiencing are related?

    http://issues.umbraco.org/issue/U4-889

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 18, 2013 @ 17:43
    Tom Fulton
    0

    Hi,

    I've not tried this, but just a thought, does this still happen if you remove the call to your IsRelated function?  Perhaps the error could be coming from there?

    -Tom

  • Braydie 148 posts 346 karma points
    Jun 18, 2013 @ 17:45
    Braydie
    0

    Hi Tom

    Thanks for your reply. Yeah I did try this, I've found that the issue is e.Cancel, not the IsRelated method. I took IsRelated out when testing, the same thing happens.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 18, 2013 @ 17:47
    Tom Fulton
    0

    Gotcha - if the barebones code is failing, might be worth reporting an issue on the issue tracker then.

    You could also try checking the log in /App_Data/LOGS to see if there's a stacktrace or anything when that error gets hit, might give a clue.

  • Braydie 148 posts 346 karma points
    Jun 19, 2013 @ 11:17
    Braydie
    0

    After some further investigation I think it is how I'm registering my event handlers. I've put an event handler that cancels deletion into a fresh install and the error doesn't occur.. However, there is no visual feedback that deletion has been cancelled - it just looks like it has deleted the node. This doesn't feel like a big deal, but I think it's important for the editor to be aware that their action hasn't been completed.

    This is the same for Media, and I had raised an issue on this in September (http://issues.umbraco.org/issue/U4-758), but I've just updated it to be for both Media and Content.

  • Braydie 148 posts 346 karma points
    Jun 19, 2013 @ 11:29
    Braydie
    0

    I've found a nasty workaround for now - rather than cancelling the event, you can throw an exception which will put the exception title in a speech bubble on the screen.

    This is certainly not a long term solution, however I suspect that this bug isn't high priority with Belle on the horizon so will have to do for the time being.

  • Braydie 148 posts 346 karma points
    Jun 19, 2013 @ 12:38
    Braydie
    0

    I've tracked the original error back to a different event handler - so there the only issue is that the tree shows the node as being deleted and no speech bubble is displayed to show the action was cancelled.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Jun 19, 2013 @ 16:14
    Tom Fulton
    0

    Thanks for the update - just upvoted.

Please Sign in or register to post replies

Write your reply to:

Draft