Console icon indicating copy to clipboard operation
Console copied to clipboard

Content Editor warning code is executed for latest version(not for selected)

Open Antonytm opened this issue 4 years ago • 0 comments

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

  1. Create 2 Sitecore users: user1 and user2.
  2. Assign sitecore\Sitecore Local Administrators role to these users
  3. Login as user1
  4. Create some item
  5. Create 5 versions of this item
  6. Switch to 2 version. (Version number doesn't matter. It should be not the latest one)
  7. Lock this item version for editing
  8. Logout
  9. Login as user2
  10. Navigate to item create on step 4
  11. 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:

  1. Passing item version to script session
  2. 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.

Antonytm avatar Jan 20 '21 13:01 Antonytm