We have moved to GitHub Issues
Created by Mads Krohn 26 Aug 2013, 21:52:57 Updated by Sebastiaan Janssen 27 Oct 2015, 12:59:38
I've seen a few people having issues with this, and I've stumbled upon it myself a few times. Whenever you are publishing nodes through scheduled publishing UmbracoContext is simply null.
Since everything regarding creation of an UmbracoContext is internal, this makes it pretty much impossible to do anything related to IPublishedContent and url generation, unless you want to try your luck with reflection and yeah, well, 'nuff said :P
I think the issue with a missing UmbracoContext has been discussed before in other issues, but I haven't seen it mentioned in regard to scheduled publishing, so here goes :)
I've found this problem also. Actually, the underlying problem is that HttpContext.Current is often (though not always?) null during a scheduled publish and UmbracoContext relies on this.
This is quite a big issue since people would expect a scheduled publish to work exactly as a manual publish, but if you have custom events that require an HttpContext then you are screwed, as I have found!
You could try to use the ApplicationContext in you event handler, it also exposes the services and are present as long as the application is started
How can i check if this is the same issue that i'm experiencing? I create a new page, go to properties, enter an "Unpublish at" date in the future and click Publish. When the date comes nothing happens.
This is still an issue on Umbraco version 7.1.4 any solution or quick fix is much appreciated.
I've been maintaining a gist to demo workarounds for different Umbraco versions. Do let me know if you run into any issues -> https://gist.github.com/sniffdk/7600822
Thanks @sniffdk The code resolved my issue.
Great to hear :)
Tried on 7.3.0. Scheduled Publishing is triggered by a request to ScheduledPublishController.Index() - and when entering that method, UmbracoContext.Current is not null - so, whatever happens (event handlers...) during publishing, the context should be here.
So... could not repro on 7.3.0. Ideas?
Haven't tested in 7.3, but will do asap. If this is somehow fixed since 7.1.4, then that is just great. Would be interesting to know what changed though :)
Hi, we are closing this issue now as we cannot replicate in 7.3.0. If you have steps to replicate the issue please re-open.
Just did a quick test and I can confirm that UmbracoContext.Current is indeed not null when doing scheduled publishing in 7.3, awesome :)
State: Can't Reproduce
Backwards Compatible: True
Affected versions: 6.1.4, 7.1.4
Due in version: