Copied to clipboard

Flag this post as spam?

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


  • Kristoffer Eriksen 185 posts 465 karma points
    Nov 08, 2011 @ 10:17
    Kristoffer Eriksen
    0

    Difference between manual publish and Publish At ?

    Hey Fellow Umbraconeers

    I've created an event, i want fired, whenever a Document of a specifik ContentType is published.

    When manually published, the event is fired, and my method, does whatever my method should do.

    But when I set a "Publish At" the event isn't fired, and my methpd isn't run.

    The Document is published, but event isn't fired

     public class CampaignManager : ApplicationBase
        {
           public CampaignManager()
            {
                Document.AfterPublish += Document_AfterPublish;
                Document.AfterUnPublish += Document_AfterUnPublish;
            }

            private void Document_AfterUnPublish(Document sender, UnPublishEventArgs e)
            {
                // DO SOMETHING
            }

            private void Document_AfterPublish(Document sender, PublishEventArgs e)
            {
                // DO SOMETHING         }

    This is obviously not all the code, but just the basics.

    I do some checkup on sender.ContentType before continuing.

    Any comments ??

     

    Best Regards

    Kristoffer

  • Kristoffer Eriksen 185 posts 465 karma points
    Nov 08, 2011 @ 10:46
    Kristoffer Eriksen
    0

    I get this error in the log when Publish At is run.

    But not when manually published

    Error publishing node: System.NullReferenceException: 
    Object reference not set to an instance of an object.    
    at umbraco.presentation.UmbracoContext.get_Current()    
    at umbraco.library.GetXmlNodeById(String id)    
    at UmbracoExamine.ContentExtensions.ToXDocument(Content node, Boolean cacheOnly)    
    at UmbracoExamine.UmbracoEventManager.content_AfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs e)    
    at umbraco.content.DocumentCacheEventHandler.Invoke(Document sender, DocumentCacheEventArgs e)   
    at umbraco.content.FireAfterUpdateDocumentCache(Document sender, DocumentCacheEventArgs e)    
    at umbraco.content.UpdateDocumentCache(Document d)    
    at umbraco.content.UpdateDocumentCache(Int32 pageId)    
    at umbraco.library.UpdateDocumentCache(Int32 DocumentId)    
    at umbraco.presentation.publishingService.CheckPublishing(Object sender)
  • Kristoffer Eriksen 185 posts 465 karma points
    Nov 08, 2011 @ 11:34
    Kristoffer Eriksen
    0

    Ok this happens on every node where I set a publish at date. Not just this specific type.

    I commented out the event, so there should not be any custom code which interfere. Is there an issue with Publish At ??

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 08, 2011 @ 11:38
    Dirk De Grave
    0

    IMHO, it should behave exactly the same, regardless of the publishing mechanism.. Add this issue to Codeplex if it isn't already listed in there. Also mention what umbraco version you're on.

     

    Cheers,

    /Dirk

  • Rodion Novoselov 694 posts 859 karma points
    Nov 08, 2011 @ 11:51
    Rodion Novoselov
    1

    Hi. It seems to be an issue that's been already mentioned on this forum. As far as I understand it's connected to the fact that scheduled publishing goes on inside a separate thread that is not a regular asp.net thread. Since that anything that depends on http request processing like cookies/session state and so on causes the process to fail. And actually, in your stack trace it's the umbraco.presentation.UmbracoContext.get_Current() call that seems to rely on existance of a cookie (like UMB_CONTEXT or like this - here I'm not sure for 100%).

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Nov 08, 2011 @ 14:08
    Tom Fulton
    0

    I think Rodion is right that there is no HttpContext in the Publish At calls.  Not sure what you are doing with it but I think I saw in another thread a similar issue with a datatype trying to use MapPath, along with a replacement (HostingEnvironment.MapPath). 

  • Kristoffer Eriksen 185 posts 465 karma points
    Nov 08, 2011 @ 14:52
    Kristoffer Eriksen
    0

    damn....I was using MapPath.....

    Will try the suggested solution, and get back to you..

  • Kristoffer Eriksen 185 posts 465 karma points
    Nov 09, 2011 @ 08:57
    Kristoffer Eriksen
    0

    HostingEnvironment did the job.

    Thank you

Please Sign in or register to post replies

Write your reply to:

Draft