22 Aug 2012
06 Dec 2007
Link to this post
You have to look at the sf_VersionItem table. When you create a new GenericContent item, there is an entry in the sf_VersionItem table for this item. Every time you go to edit this item, before you publish, the version number is incremented and another entry in the sf_VersionItem table is made. After editing say three times, your version should be four. At this point if you publish the item, the version is now set to three.
From digging into the code, it seems that the problem is in the CommitChanges method in Telerik.Versioning.Data.DefaultProvider. Here, the current item is being set as (IVersionItem) newItem. Another member orgItem, also IVersionItem, is being set as the current version -1. So in our scenario, newItem is version four and orgItem is version three. It then deletes version four and saves the data for version four as version three. So the end result is a published item with a version one less than the last version created.
We have been extending the GenericContent module and using the version number along with the item Guid to store the different versions. This way as you roll back an item, we can retrieve the appropriate data for the version rolled back to. This is a problem with the publishing when versioning is set to false and workflow is set to true. As I mentioned above, before you publish everything works just fine. Each edit gives you a new version number. The problem is that when you publish and the last version number is decremented by one, the versioning is no longer correct. If in the example above we save data using the version four and on publish the actual GenericContent item's version is set back to three, then our data does not match up.
This problem only seems to occur when the versioning is set to false and the workflow is set to true. If both are set to false or both are set to true, then everything seems to work without any problems. If versioning is set to false, then the version number should never be incremented.