November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I solved it for now by always using SaveAction.ForceCurrentVersion when saving from job and do a check in the event if SaveContentEventArgs.ForceCurrentVersion is true.
We usually set up a "service account" user to use for automated tasks, such as scheduled jobs, etc.
var humanUser = PrincipalInfo.CurrentPrincipal; var userImpersonation = ServiceLocator.Current.GetInstance<IUserImpersonation>(); userImpersonation.CreatePrincipal("SomeServiceAccount"); // Do work as 'SomeServiceAccount' PrincipalInfo.CurrentPrincipal = humanUser;
This way we get more relevant version history (as we can see what has been done by an editor and what has been done by an integration, scheduled job, or such) and at the same time we can use current user info to determine whether specific validation should take place.
It also avoids scheduled jobs being run as anonymous users, forcing developers to add SaveAction.NoAccess when working with IContentRepository methods.
I realize this doesn't exactly answer your original question, but suppressing/avoiding publishing events can have adverse (unintentional) side-effects. :)
This looks exactly like what we'll set up when we find SaveAction.Patch isn't enough. Thank you.
My goal is to trigger publish events only when a page is published by an editor or a certain condition is met.
We have some jobs that parse, populate and republishes content on a regular basis but I would like to not trigger publish events when triggered by jobs.
Any ideas?