We have been using the code that was working quite well:
_contentRepository.Save(clone, SaveAction.Save | SaveAction.ForceCurrentVersion, AccessLevel.NoAccess);
However, after upgrade, this gives the error: "EPiServer.Core.EPiServerException: Using SaveAction.Save + SaveAction.ForceCurrentVersion on published content is not allowed".
Is there a reason why the behavior was changed or is this a bug?
It was one of the breakng change in EPiServer 8.
The reason is described in:
in section Saving published content with save action Save and ForceCurrentVersion
Thx a lot, Grzegorz, I didn't manage to find this.
Do you understand this part: "You are supposed to pass in either Save on versions or Publish to modify a published content without changing status."
I can't publish, since I don't want to change the ChangedBy value (publish changes it). When I save, the new version is not forced, so the page is not changed.
I tried using SaveAction.Publish | SaveAction.SkipSetCommonDraft (since I've noticed the latter is new to SaveAction), however, this works as it should when I first modify the page, but when I do the same the second time, I see the previously published page (instead of the first published one).
Ah no, it's been a while since I wrote that code. The combination Save and ForceCurrentVersion does change the ChangedBy, but at least it doesn't change Changed. Then, in on publishing event, I set a RealChangedBy value (this is not called with Save | ForceCurrentVersion, so that worked well).
Now, when I switched to Published, the event is called and RealChangedBy is set anyways. So, I need a way to know if the page is "really" changed. I am now checking the following:
((SaveContentEventArgs)e).Action != SaveAction.Publish | SaveAction.SkipSetCommonDraft,
I'll dig deeper if EPi uses the same combination elsewhere.