Copied to clipboard

Flag this post as spam?

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


  • higgsy 65 posts 92 karma points
    Sep 14, 2012 @ 20:41
    higgsy
    0

    Cancelling Publish event in 4.9

    Hello,

    I've just started a site based on 4.9.0. I want to cancel the publish event if certain conditions arent met. My code is pretty straight forward:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using umbraco.BusinessLogic;
    
    /// <summary>
    /// Summary description for Global
    /// </summary>
    public class Global : umbraco.BusinessLogic.ApplicationBase
    {
        bool _beforePublishEventAttached;
    
        public Global()
        {
            if (!_beforePublishEventAttached)
            {
                umbraco.cms.businesslogic.web.Document.BeforePublish += new umbraco.cms.businesslogic.web.Document.PublishEventHandler(Document_BeforePublish);
            }
        }
    
        void Document_BeforePublish(umbraco.cms.businesslogic.web.Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
        {
            if (sender.getProperty("showCallToAction") != null)
            {
                e.Cancel = true;
            }
            _beforePublishEventAttached = true;
        }
    }

    I have two questions/problems:

    1) I thought that 4.8 included a method for returning a friendly error/warning message instead of the standard "Error - cancelled by 3rd party..." http://issues.umbraco.org/issue/U4-84. But I can't find any documentation that explains how this can be done, the API still only seems to have a Cancel property.

    2) The code above does cancel the publish (I can confirm by going to the public url for the page and checking whether the updates have been published), but it also throws a Js error and prevents the umbraco UI from re-loading, seen below. Either my code is wrong, or there is some form of bug....any ideas anyone?

    Thanks in advance

    Al

  • higgsy 65 posts 92 karma points
    Sep 20, 2012 @ 21:04
    higgsy
    0

    Hi all,

    Just back on the project. Can I just check whether anyone has had this same problem? Im starting to suspect its some sort of deodgy install from version 4.9.

     

    Any thoughts anyone?

    Thanks

    Al

  • higgsy 65 posts 92 karma points
    Sep 20, 2012 @ 22:37
    higgsy
    0

    I've created a bug for this: http://issues.umbraco.org/issue/U4-889

    What a shame, as I now need to port my work across to 4.8.1 and miss out on the great updates in 4.9.0!

  • Dejan Ostojic 10 posts 54 karma points
    Oct 01, 2012 @ 11:25
    Dejan Ostojic
    0

    Hello,

    Any news regarding this issue? I see that you created a bug for this a week ago, but has it been solved until now?

    I haven't notice this bug until today, but now I have a big problem with this issue because the website that I upgraded to the latest "stable" version 4.9 doesn't work correctly now. If I knew for this issue I wouldn't make the upgrade.

    Thanks,
    Dejan

  • higgsy 65 posts 92 karma points
    Oct 01, 2012 @ 12:54
    higgsy
    0

    No no news yet, not even recognition of the bug. It's a real dissapointment to be honest, this Agile approach to development and relases has fallen over so soon!

  • Dejan Ostojic 10 posts 54 karma points
    Oct 03, 2012 @ 13:56
    Dejan Ostojic
    0

    Hello again,

    I've just found where the problem comes from. To solve this issue you should:

    • download the Umbraco 4.9 source code
    • open file: \src\Umbraco.Web\umbraco.presentation\umbraco\editContent.aspx.cs
    • go to the line 330
    • there's missing "speachBubbles" for area parameter, so that line should be replaced with: ClientTools.ShowSpeechBubble(speechBubbleIcon.error, ui.Text("error"), ui.Text("speechBubbles", "contentPublishedFailedByEvent", null));
    • build the project

    I hope this bug will be fixed with the next release, but until then you can manually change the source code and use that new version of the umbraco.dll.

    Regards,
    Dejan

     

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Oct 27, 2012 @ 16:08
    Darren Ferguson
    0

    I've submitted a patch for this via Codeplex. I've also made the core team aware of this issue.

    @higgsy - I don't think you are being fair in your criticism here - a re-ordering of a language file caused this - very obscure and hard to have detected in testing.

    Also http://issues.umbraco.org/issue/U4-84 was a fix which changed the severity of the message from an error to a warning. At present you still can't control the text of the speech bubble.

    @Dejan - if you had made the fix it is really easy to submit it to the core: http://umbraco.codeplex.com/SourceControl/UploadPatch.aspx

  • Stephen 767 posts 2273 karma points c-trib
    Oct 29, 2012 @ 09:50
    Stephen
    0

    Have commited changeset f3a3bdaf6329 in 4.10 that fixes that issue. Have updated http://issues.umbraco.org/issue/U4-889 accordingly.

Please Sign in or register to post replies

Write your reply to:

Draft