It is still so under the covers but you can use public virtual bool and null will be false, so you really don't have to care about that behaviour anymore.
There is a bug regarding saving pages programmatically where it may pick up an older version and apply the changes to instead of the latest version, this happen when you get the published page and programmatically make changes to it and then publish. This bug is not visible in edit mode since it has custom code to pick the latest version that does not have this bug. For now you will have to contact support to get a fix for that if that is the problem you are facing.
Ah, that bug description fits like a glove to the probs I'm seeing. Will contact support. Thanks!
The answer I'm getting from support is that no fix or patch will be available and that the problem will persist until the next relasese (q2 / q3). This is clearly unacceptable and puts all our EPi7-projects on hold, or even worse, in crisis mode. We will take this upstairs at EPi.
Per, could SaveAction.ForceNewVersion be used as a workaround for that bug? Seems like something I ran into a couple of days ago and in that case it worked.
Hi Johan,
We do realize that this is a severe problem that needs to be adressed sooner rather than later. The current resolution of the bug unfortunately makes it unsuitable to be distributed as a hotfix/patch but we are looking into an alternative way of fixing it. We cannot give any date for when this will be available but you should not need to wait until Q2. In the mean time you can use the workaround suggested by Joel.
So can I just replace SaveAction.Publish with SaveAction.ForceNewVersion in my code or do I need to use something like "SaveAction.Publish | SaveAction.ForceNewVersion" for all calls DataFactory.Instance.Save()? The calls might handle both existing and new PageData objects.
Edit: Or do I need to change my code so that it uses different save actions for new or existing pages?
You need both flags for it to work, so SaveAction.Publish | SaveAction.ForceNewVersion
Great! Thanks! Haven't seen the previous symptoms anymore after changing.
Can EPi post some more info here on which SaveActions that can trigger the bug?
A direct link for the bug list that works would also do it if it has that info.
Bug #92742 : When saving and publishing an existing page with code some properties previously published values are reset
When saving an existing page with DataFactory.Save() some properties previously published are reset. The bug is in the code that selects a version if no parameter is saying which version to update. So if you load a new version of a page yourself and then save it, or create a new page or use ForceNewVersion/ForceCurrentVersion you will not enter the code that determines which version to update (possible workarounds).
Steps to Reproduce:
[Display(GroupName = SystemTabNames.Content)]
public virtual string String1 { get; set; }
[Display(GroupName = SystemTabNames.Content)]
public virtual string String2 { get; set; }
var reference = new ContentReference(6); // Insert relevant page id
var page = DataFactory.Instance.Get<StandardPage>(reference).CreateWritableClone() as StandardPage;
page.String2 = "string 2";
DataFactory.Instance.Save(page, SaveAction.Publish, AccessLevel.NoAccess);
Earlier a bool property has never been false, only null or true.
Is this still so and is the best practise to use "public virtual bool" or nullable bool?
Asking because I'm getting some weird behaviour when saving a page programmatically.