Hi, Juraj (and Kenny).
I am updating here to help others, since it helped us.
The workaround in this post solved the same issue in a Kentico 10 site for us.
So unfortunately, a Kentico 10 upgrade did NOT solve the bug in our case.
Details: we use a handler on DocumentEvents.Insert.After which copies and inserts some child documents when a certain parent document type is inserted in the CMS tree.
The handler worked in Kentico version 8.1, but after upgrade to Kentico 10.0.50 an exception was thrown by:
var copy = DocumentHelper.CopyDocument(node, targetNode, true, treeProvider);
Wrapping the entire block of code per Juraj's workaround solved the issue:
using (new DocumentActionContext { ResetChanges = true })
{
(...our existing code here...)
}
The partial stack trace (to increase findability of this post) is:
An error occurred when saving data. Please see event log for more details.
Message: The new culture version cannot be under different parent node than original node
Exception type: System.Exception
Stack trace:
at CMS.DocumentEngine.TreeNode.InsertAsNewCultureVersionInternal(String cultureCode)
at CMS.DocumentEngine.TreeNode.InsertAsNewCultureVersion(String cultureCode, Boolean useDocumentHelper)
at CMS.DocumentEngine.DocumentCopier.InsertNewDocumentCultureVersion(TreeNode targetCultureNode)
at CMS.DocumentEngine.DocumentCopier.CopyCultureVersion(TreeNode sourceCultureNode, TreeNode firstCopiedCultureNode)
at CMS.DocumentEngine.DocumentWithVersionsCopier.CopyCultureVersion(TreeNode sourceCultureNode, TreeNode firstCopiedCultureNode)
at CMS.DocumentEngine.DocumentCopier.CopyCultureVersions()
at CMS.DocumentEngine.DocumentCopier.Copy()
at CMS.DocumentEngine.DocumentHelper.CopyDocument(TreeNode node, TreeNode target, Boolean includeChildNodes, TreeProvider tree)
(... more lines below from our custom code components...)
Cheers,
Laurence