Saving drafts with action SaveAction.Patch saves incorrect version

Found in

EPiServer.Commerce 11.2.1

Fixed in

EPiServer.Commerce 11.2.6

Created

Sep 18 2017

Updated

Oct 06 2017

Area

Core

State

Closed, Fixed and tested


Description

Steps to reproduce

1. Install QuickSilver 11.2.2.
2. Create a save event hook in the method Initialize of SiteInitialization class.

ServiceLocator.Current.GetInstance().SavedContent += (object sender, ContentEventArgs e) => 
{
if (e is SaveContentEventArgs)
{
var arg = e as SaveContentEventArgs;
 
if (arg.ForceCurrentVersion)
{
return;
}
}
var currentContent = e.Content as CatalogContentBase;
var targetContent = currentContent.CreateWritableClone();
 
var action = SaveAction.Save | SaveAction.SkipValidation | SaveAction.ForceCurrentVersion;
 
ServiceLocator.Current.GetInstance().Save(targetContent, action, AccessLevel.NoAccess);
};

3. Change the brand of the product without publishing.

Expected: The change is not displayed on front end page because it's a draft version.
Actual: The change is displayed on the front end page even though it's a draft version.