Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename-Item do not take info account language version #1287

Closed
alan-null opened this issue Oct 14, 2022 · 3 comments
Closed

Rename-Item do not take info account language version #1287

alan-null opened this issue Oct 14, 2022 · 3 comments
Assignees
Labels
-release-highlight Exciting change that should be highlighted in the release notes and celebrated by SPE fans. area-commands Involves functions and cmdlets. bug Oops! Sorry for the inconvenience. impact-behaviour-change Nothing to be worried about. Now even better than before!
Milestone

Comments

@alan-null
Copy link
Member

Using cmldet in a following way result in creating new language versions

$item | Rename-Item -Newname "OK"

where $item is only version other than en

Expected Behavior

No extensive language versions should be created

Actual Behavior

If you rename item with da version you will get extra en version

Steps to Reproduce the Problem

  • add Danish language to the system
  • create new item named da under /sitecore/content/Home
  • invoke script Get-Item -Path '/sitecore/content/Home/da' -Language "da" | Rename-Item -NewName "da1"
@alan-null alan-null added bug Oops! Sorry for the inconvenience. area-commands Involves functions and cmdlets. labels Oct 14, 2022
@alan-null alan-null self-assigned this Oct 14, 2022
@michaellwest
Copy link
Member

@alan-null Are there other commands that do not properly handle the language?

@alan-null
Copy link
Member Author

@michaellwest I don't know. I haven't checked

@michaellwest michaellwest added impact-behaviour-change Nothing to be worried about. Now even better than before! -release-highlight Exciting change that should be highlighted in the release notes and celebrated by SPE fans. labels Aug 2, 2023
@michaellwest michaellwest added this to the 7.0 milestone Aug 2, 2023
alan-null added a commit to SXA-DEV/SitecorePowerShell that referenced this issue Feb 1, 2024
@AdamNaj AdamNaj modified the milestones: 7.0, 8.0 May 20, 2024
@AdamNaj AdamNaj self-assigned this May 20, 2024
@AdamNaj
Copy link
Member

AdamNaj commented May 20, 2024

It feels a bit like the PR is making assumptions, like:

  • The rename happens right after the item is retrieved (As the value requires wrapping to happen to remember the language)
  • Multiple consecutive renames may not be on the items with the same languages missing, e.g. if they are coming from a some table.
  • The value is never wiped.

But based on the case here... we're modifying Name which is version independent, which means we need ANY existing version to avoid the problem. Hence the solution provided just looks for the first existing version and does the operation on that.

Additionally found that the same problem may exist in Move-Item and Transfer-Item even though I didn't necessarily do much work to reproduce those.

Testing Script for Rename-Item:

$name1="Home2"
$name2="Home1"
$exoticLanguage = "pl-PL"

if(Test-Path "master:\content\$name1"){
    $sourcePath = "master:\content\$name1"
    $newName = $name2
    $destinationPath = "master:\content\$name2"
} else {
    
    $sourcePath = "master:\content\$name2"
    $newName = $name1
    $destinationPath = "master:\content\$name1"
    if(!(Test-Path "master:\content\$name2")){
        New-Item $sourcePath -Language $exoticLanguage -ItemType "Sample/Sample Item" | Out-Null
    }
}

Remove-ItemVersion -Path $sourcePath -Language "en" -Version "*"
Get-Item $sourcePath -Language $exoticLanguage | Rename-Item -Newname $newName

Get-Item $destinationPath -Language * -Version *

@AdamNaj AdamNaj closed this as completed May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-release-highlight Exciting change that should be highlighted in the release notes and celebrated by SPE fans. area-commands Involves functions and cmdlets. bug Oops! Sorry for the inconvenience. impact-behaviour-change Nothing to be worried about. Now even better than before!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants