Copied to clipboard

Flag this post as spam?

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

  • Adrian 38 posts 117 karma points
    Sep 25, 2013 @ 17:57

    Publish At throws Null Reference Within uDateFoldersy

    Anthony as requested.

    2013-09-25 14:12:04,932 [18] INFO  Umbraco.Core.Publishing.PublishingStrategy - [Thread 16] Content 'The Editorial Board Blog' with Id '4443' has been published.
    2013-09-25 14:12:04,995 [18] ERROR umbraco.presentation.publishingService - [Thread 16] Error publishing node 4443
    System.NullReferenceException: Object reference not set to an instance of an object.
       at uDateFoldersy.UmbracoEvents.UmbracoNodeEventsForDateFolders.Flagged(String cachePrefix, String suffix)
       at uDateFoldersy.UmbracoEvents.UmbracoNodeEventsForDateFolders.ContentService_Saved(IContentService sender, SaveEventArgs`1 e)
       at Umbraco.Core.Events.TypedEventHandler`2.Invoke(TSender sender, TEventArgs e)
       at Umbraco.Core.Services.ContentService.SaveAndPublishDo(IContent content, Int32 userId, Boolean raiseEvents)
       at umbraco.cms.businesslogic.web.Document.SaveAndPublishWithResult(User u)
       at umbraco.cms.businesslogic.web.Document.SaveAndPublish(User u)
       at umbraco.presentation.publishingService.CheckPublishing(Object sender)

    I think I may have fixed it, I pulled your code from bitbucket, added some logging. From some other searches on HttpContext.Current.Items being null, One suggestion was to inherit IRequiresSessionState.

    Rebuilding and copying over seemed to fix the exception and the article appears to be publishing correctly...

  • Adrian 38 posts 117 karma points
    Sep 25, 2013 @ 18:04

    Darn doesn't seem to be working.... :-(

  • Adrian 38 posts 117 karma points
    Sep 26, 2013 @ 10:56

    Changing HttpContext.Current.Items to use HttpRuntime.Cache has fixed this problem when uDatesFoldersy is invoked by the Timer. So article will now get published when using Publish At and Remove At.

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Sep 26, 2013 @ 12:30
    Anthony Dang

    That will probably cause some issues.

    Current.Items is request specific. Using cache means that the value stays around for a period of time. If you use it then you must dump the cache manually. I don't really think its a good idea to use.

    The value I'm storying is just for the request. I have no idea why it's crashing now though.


  • Adrian 38 posts 117 karma points
    Sep 26, 2013 @ 13:23

    I clipped the stack trace above here's the full trace showing the mscorlib.dll!System.Threading.TimerQueueTimer.Fire() not sure where in Umbraco the timer get set up though.....

    uDateFoldersy.dll!uDateFoldersy.UmbracoEvents.UmbracoNodeEventsForDateFolders.Flagged(string cachePrefix, string suffix) Line 185   C#
    uDateFoldersy.dll!uDateFoldersy.UmbracoEvents.UmbracoNodeEventsForDateFolders.ContentService_Saved(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent> e) Line 143 + 0x26 bytes   C#
    Umbraco.Core.dll!Umbraco.Core.Events.EventExtensions.RaiseEvent<Umbraco.Core.Services.IContentService,Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent>>(Umbraco.Core.Events.TypedEventHandler<Umbraco.Core.Services.IContentService,Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent>> eventHandler, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent> args, Umbraco.Core.Services.IContentService sender) + 0x50 bytes  
    Umbraco.Core.dll!Umbraco.Core.Services.ContentService.SaveAndPublishDo(Umbraco.Core.Models.IContent content, int userId, bool raiseEvents) + 0x8c2 bytes    
    Umbraco.Core.dll!Umbraco.Core.Services.ContentService.SaveAndPublishInternal(Umbraco.Core.Models.IContent content, int userId, bool raiseEvents) + 0x4f bytes   
    cms.dll!umbraco.cms.businesslogic.web.Document.SaveAndPublishWithResult(umbraco.BusinessLogic.User u) + 0x39a bytes 
    cms.dll!umbraco.cms.businesslogic.web.Document.SaveAndPublish(umbraco.BusinessLogic.User u) + 0x55 bytes    
    umbraco.dll!umbraco.presentation.publishingService.CheckPublishing(object sender) + 0x1a6 bytes 
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x285 bytes 
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) + 0x9 bytes   
    mscorlib.dll!System.Threading.TimerQueueTimer.CallCallback() + 0xde bytes   
    mscorlib.dll!System.Threading.TimerQueueTimer.Fire() + 0x10e bytes  
    mscorlib.dll!System.Threading.TimerQueue.FireNextTimers() + 0x224 bytes 
    [Native to Managed Transition]  
    [Appdomain Transition]  
    [Native to Managed Transition]  
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Sep 26, 2013 @ 13:38
    Anthony Dang


    I'll need to spend some time to investigate.


  • Adrian 38 posts 117 karma points
    Sep 26, 2013 @ 16:21

    I've now added a return from ContentService_Saved if the HttpContext.Current is null. This appears to work for both Publish At and Remove At.

       void ContentService_Saved(IContentService sender, Umbraco.Core.Events.SaveEventArgs<IContent> e)
            if (!ConfigReader.Instance.UseAutoDateFolders()) { return; }
        // If this event isn't invoked from a Request then HttpContext.Current will be null.
        // Which MAY indicate that the event was fired by a timer to handler the
        // Publish At/Remove At functionality. It would be better if the event object 
        // provided some context to state this.
        if (HttpContext.Current == null) { return; }
Please Sign in or register to post replies

Write your reply to: