Console
Console copied to clipboard
Content Editor warning code is executed for latest version(not for selected)
Expected Behavior
I as Content Editor want Sitecore Powershell Warnings to be executed for the selected item version.
Actual Behavior
Sitecore Powershell Warnings are executed in the context of the latest item version.
Steps to Reproduce the Problem
- Create 2 Sitecore users: user1 and user2.
- Assign sitecore\Sitecore Local Administrators role to these users
- Login as user1
- Create some item
- Create 5 versions of this item
- Switch to 2 version. (Version number doesn't matter. It should be not the latest one)
- Lock this item version for editing
- Logout
- Login as user2
- Navigate to item create on step 4
- Switch to 2 version. (version from step 6)
Expected result: Warning 'Elevated Unlock' should be shown. Message 'Use elevated privileges to unlock the current item.' should be present and 'Unlock' button should be available to unlock this version. Actual result: Warning 'Elevated Unlock' is absent
Investigation result:
Enable rule takes current item using $item = Get-Item -Path "." code, which ignores the version.
However, I looked on Spe.Integrations.Pipelines.ContentEditorWarningScript implementation and it looks like only path is transferred to SPE, via scriptSession.SetItemLocationContext. That is why the fix should contain 2 parts:
- Passing item version to script session
- Getting item version from context and execute 'Enable Rule' using that version
-
[X] Tested issue with clean install of Sitecore and the latest available version of SPE.
-
[X] Asked questions on the Sitecore Slack Chat channel.
-
[X] Reviewed questions and answers on the Sitecore Stack Exchange.