Fix U4-2372 Save and Publish creates fewer versions #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is to fix http://issues.umbraco.org/issue/U4-2372.
Previous to 6.1.0, when this line in ContentRepository was reached:
bool shouldCreateNewVersion = (((ICanBeDirty)entity).IsPropertyDirty("Published") && publishedState != PublishedState.Unpublished) || ((ICanBeDirty)entity).IsPropertyDirty("Language");
the property Published was dirty when a Save and Publish was initiated from the front end.
This is no longer always the case. Because of this, this line in ContentRepository:
((Content)entity).UpdatingEntity();
is being called only for new Content and for Content moving between Unpublished to Published. The UpdatingEntity method is responsible for setting a new guid on the Version property on the Content. Because of this, only new Content and Content moving between Unpublished to Published is getting a new version number. In this context, by unpublished, I mean Content that has not yet been published before the Save And Publish was initiated.
I've changed the check in shouldCreateNewVersion to be based on the actual Published property itself. This restores the original functionality of a new cmsDocument row being created everytime a user clicks Save and Publish and this results in a successful Publish.
Please note the issue in http://issues.umbraco.org/issue/U4-2361 appears worse as there are more versions being saved so this will also need to be fixed.