Skip to content

Instantly share code, notes, and snippets.

@sniffdk
Last active August 29, 2015 13:58
Show Gist options
  • Save sniffdk/9931534 to your computer and use it in GitHub Desktop.
Save sniffdk/9931534 to your computer and use it in GitHub Desktop.
Fix re-publish of already published descendants in Umbraco
public class UmbracoHooks : IApplicationEventHandler
{
private static readonly List<int> PublishFixes = new List<int>();
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Publishing += (sender, args) =>
{
foreach (var contentItem in args.PublishedEntities)
{
if (contentItem.HasPublishedVersion()) return;
lock (PublishFixes)
{
if (!PublishFixes.Contains(contentItem.Id))
{
PublishFixes.Add(contentItem.Id);
}
}
}
};
ContentService.Published += (sender, args) =>
{
foreach (var contentItem in args.PublishedEntities)
{
lock (PublishFixes)
{
if (!PublishFixes.Contains(contentItem.Id)) return;
library.RefreshContent();
PublishFixes.Remove(contentItem.Id);
}
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment