skttl / umbraco-unversion

A content un-versioning package for Umbraco 8.4+
https://our.umbraco.org/projects/website-utilities/unversion/
MIT License
13 stars 10 forks source link

unVersion not working on 8.11.1? #31

Open jacobsoee opened 3 years ago

jacobsoee commented 3 years ago

Hello there.

It doesnt seem like this package work on 8.11.1, sadly. When fetching all versions for a node, not all of them appears.

var allVersions = _contentService.GetVersionsSlim(content.Id, 0, int.MaxValue).ToList();

allVersions will in my example have 10-12 entries, but the node has more than 800 versions who matches the predicate set in the config file.

I downloaded the source code, and debugged it, trying to find a solution, without luck.

On other nodes (which are bigger than my first example) im getting an InvalidOperationException: Cannot delete the published version. It is thrown in the core of Umbraco, so im afraid its because they've made a change to their contentservice.

Is this fixable somehow, and is this a known problem? Please tell me if you need more in depth information. :)

jaandrews commented 3 years ago

@jacobsoee It worked for me when I tried this in umbraco 8.14.1. I configured it do delete all history except for the 5 most recent and when I open the rollback panel, there are only 4 options as expected (4 plus the current version sums up to 5).

Do note that the information in the history panel is not updated though. This is because umbraco pulls that information from the umbracoLog table, and that table is not modified when a version is deleted. There's no way to connect these log entries to particular versions unfortunately with the current tables. A new joining table would need to be created to connect logs with versions and the info section would need to be tweaked to use an api to uses that table to join the umbracoContentVersion and umbracoLog tables. You can see the data currently pulled into the history block with the following sql query.

SELECT *
FROM [dbo].[umbracoLog]
WHERE NodeId = {node id}

You can delete the unwanted entries from this table to data up the data in the info tab manually, though you'll want to backup the database before trying just in case that causes problems.