This was the case in v7 as well. There has always been the ability to had infinite versions saved. That is why someone created UnVersion to help remove historic versions, so it's not a new behaviour.
I believe you could look at the source of UnVersion and potentially do a very similar operation in your own custom event handler for save and publish in v8 to achieve the same thing.
What I ended up with was doing this, which works fine.
public class SaveComposer : IUserComposer
{
public void Compose(Composition composition)
{
// Append our component to the collection of Components
// It will be the last one to be run
composition.Components().Append<SaveComponent>();
}
}
public class SaveComponent : IComponent
{
// initialize: runs once when Umbraco starts
public void Initialize()
{
ContentService.Saving += ContentService_Saving;
}
// terminate: runs once when Umbraco stops
public void Terminate()
{ }
private void ContentService_Saving(IContentService sender, ContentSavingEventArgs e)
{
foreach (var content in e.SavedEntities)
{
// Delete versions older than 48 hours
var date = DateTime.Now.AddDays(-2);
sender.DeleteVersions(content.Id, date);
}
}
}
Limit versions in Umbraco 8
Hi
Is there a way to limit the number of versions created when saving and publishing nodes in Umbraco 8?
The Unversion package is v7 only.
Good question. Are there unlimited versions now? Sounds like database can grow unnecessary big if that is the case...
Hi Rodolphe,
This was the case in v7 as well. There has always been the ability to had infinite versions saved. That is why someone created UnVersion to help remove historic versions, so it's not a new behaviour.
Thanks
Nik
Hi Michael,
I believe you could look at the source of UnVersion and potentially do a very similar operation in your own custom event handler for save and publish in v8 to achieve the same thing.
Thanks
Nik
What I ended up with was doing this, which works fine.
is working on a reply...