Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VersionedCollector doesn't delete versions that were published in the past #20

Open
matthewrayner opened this issue Aug 19, 2021 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@matthewrayner
Copy link
Contributor

matthewrayner commented Aug 19, 2021

What is the reasoning behind this? I see that you mentioned isPublishedInLocale() as a reason but I don't see why.

I have SiteTree objects that have hundreds of different versions but as some of the versions were published they haven't been deleted even if they are hundreds of versions behind.

This is the line of code with the comment I mentioned above.

// Include only draft edits versions
// as we don't want to delete publish versions because these drive isPublishedInLocale()
$baseTable . '."WasPublished"' => 0,

@matthewrayner matthewrayner changed the title Versioned collector doesn't delete versions that were published in the past VersionedCollector doesn't delete versions that were published in the past Aug 19, 2021
@michalkleiner
Copy link
Collaborator

Maybe we can adjust the code comment to better explain the primary/basic intentions. My understanding of that is that we can safely remove draft versions (as defined by the delete/keep rules), and not touching any published versions. If you want to go beyond that, the module provides extension points where you can add custom items to the collections.

What's your view on that, @brettt89?

@brettt89
Copy link
Owner

The original code for this was pulled from a live project, so it was originally quite specific (though I did expand further with extensions etc). Personally my preference is to have the default be the "most common use-case". Having a method for enabling/disabling a filter on WasPublished (so these can be include/excluded as needed) kinda makes sense to me.

The extensions were intially added for support for Versioned extensions (e.g. Fluent) as not all projects use this, but the intent was always that others could also use these extensions to customize as needed.

There is probably a balance to be had here, but the way I kind look at is "If you can do it in Versioned module out of the box, then we should also support it out of the box" - (e.g via a switching method or something).

Does that make sense to you as well? Happy to hear other peoples opinions on this?

@brettt89
Copy link
Owner

The more I think about, @matthewrayner 's use-case might be the more common approach for Silverstripe websites. We originally took a very cautious approach to deleting these records (which is why WasPublished was always set to 0 as we didn't want to risk deleting anything that was live).

But being able to garbage collect old draft versions, for published pages seems like a pretty straight forward / common use-case for this module. I would probably say that if you wanted to keep ALL your draft content for published pages, that should be an "opt-in" modification (E.g. through extensions or maybe a enable/disable method).

@michalkleiner
Copy link
Collaborator

Yep, I'm all for flexibility if the defaults are safe — I'd only allow removing published versions after explicit config change by a dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants