U4-2589 - Save and Publish is not creating version of document

Created by Yakov Lebski 06 Aug 2013, 09:52:33 Updated by Shannon Deminick 08 Aug 2013, 00:42:25

  1. Open any node
  2. Change some text property
  3. Click on Save and Publish
  4. Open Rollback option -> last version updated by new date, no new version created
  5. Click save on the same node
  6. open Rollback option -> new version created
  7. click Save and Publish
  8. open Rollback option -> another new version created

Save and Publish must create version on each action. The same behavior reproduce on api, (Document and ContentService)

Comments

Shannon Deminick 07 Aug 2013, 01:01:52

In the source code, this is caused by this code here in the ContentRepository:

//A new version should only be created if published state (or language) has changed bool shouldCreateNewVersion = (((ICanBeDirty)entity).IsPropertyDirty("Published") && publishedState != PublishedState.Unpublished) || ((ICanBeDirty)entity).IsPropertyDirty("Language"); if (shouldCreateNewVersion) { //Updates Modified date and Version Guid ((Content)entity).UpdatingEntity(); }

So in fact, we are only ever creating a new version when the published status or language changes. It would appear that even if you have a published item pending, change some values and then click save again, it will still not create another version (in order to rollback to).


Shannon Deminick 07 Aug 2013, 01:39:44

Fixed in revision: 1b9f0715813a90bca6f227bfe35cbb4d4ea3256a


Morten Christensen 07 Aug 2013, 06:19:19

Shannon, the logic in that code snippet was added so that new versions are only created between saves and publish and not for every save. This was do mimic the old logic, so it should currently be as its always been. But guess we can test that with a version 4 install.

Pretty sure that any change to the logic that make the repo create a new version on EVERY save will make the number of versions explode beyond belief, so please ensure that this is desired before changing it.

This is how it currently works: New Content - first version created Update text and Save - no new version is created Click save and publish - new version is created Update text and save draft - new version is created Update more text- no new version is created Click save and publish - new version is created Click save and publish again - new version is created


Shannon Deminick 07 Aug 2013, 06:41:40

Yup I figured that out but that means you can never rollback between revisions unless you are publishing or unpublishing or changing a language.

My fix doesn't create a new version on ever save, ONLY when:

  • A property value is changed
  • The published state is changed
  • The language is changed

So basically I just added one new check, if a property value has changed we also save a new value.

If that is not the way it should work then we can revert but seems to me that the whole point of rollback is that you can rollback to different changes that were made, regardless of whether the published state has been changed.


Morten Christensen 07 Aug 2013, 07:10:24

Its still too much compared to how it used to be. In the legacy code a new version was only created after a Publish. All saves after a Publish would update the same version.

But I think I might have figured out the issue. But not sure I remember the recent 6.1 changes to dirty tracking correctly... If current version is Published and I update the Published property again to be Published (true), so its changed from true to true (yeah, not really a change but the property has been touched) then that property wouldn't be Dirty right? Which is what we check when we check whether or not a new version should be created. If I'm right then the check we did in 6.0.x is not valid in 6.1.x. So for the ChangePublishState on Content we actually need to ensure that either the Published property or something else is marked as dirty so we can use it for ShouldCreateNewVersion check.


Shannon Deminick 07 Aug 2013, 07:25:05

But that still doesn't solve Yakov's issue. TBH I don't know what it did in 4.x so can't verify that we only created new versions when the published state was changed. I think I understand the publish check that you are talking about, but that is easily solved with the code I added to fix this issue. We shouldn't be creating a new published version if someone is just re-publishing without changing any property values, but we should if the property values are changed... which is what my commit already solves. But from the sounds of it, you're saying that if it is not published we should not create new versions if property values are changed and the document is just saved ?

To confirm, is this what you are getting at... We would create a new version when:

  • A property value is changed AND the state of the content item is published (meaning it could have already been published, or is currently being published)
  • The published state is changed
  • The language is changed

(but doesn't solve Yakov's who would like a new version saved when a property value changes regardless of published state)


Morten Christensen 07 Aug 2013, 07:50:56

Whether a property has been updated didnt matter (legacy wise), but okay that's another way of checking - assuming the 'properties' goes beyond the Properties collection and also includes Name, dates etc. New versions should ONLY be created between Publish actions (and that was also the case between two Publish actions regardless of anything having been changed). But the most important thing right now is to respect that Legacy is king ;) Save, Save, Save = one draft version Save, Publish, Save = 3 versions Save, Publish, Publish = 3 versions (I agree that if there are no changes between Publish then it shouldn't create a new version). But keep in mind that this is only when using "Save and Publish".

From Yakov's report I understand that a new version should be created every time he clicks "Save and Publish", which is right. But not on every Save. A version for every save is a feature request as that has never been the case.


Shannon Deminick 07 Aug 2013, 07:57:12

Ah yeah, sorry I forgot that he was also doing SaveAndPublish!

Ok cool, well I'll fix this up to do what is expected. I'll also put in a check for dirty properties on IContent (not just user properties).


Shannon Deminick 08 Aug 2013, 00:42:21

Ok, thats all fixed up in 0fbc32a87f3bf5ce5eee29c290bf83f052e97e37 with tests


Priority: Show-stopper

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 6.1.1, 6.1.2, 6.1.3

Due in version: 6.1.4

Sprint:

Story Points:

Cycle: