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

Fixing NRE when publishing item with LocalizationPart removed (Lombiq Technologies: OCORE-102) #12401

Merged
merged 1 commit into from
Sep 13, 2022

Conversation

Piedone
Copy link
Member

@Piedone Piedone commented Sep 13, 2022

Looks like an oversight since line 103 handles this in the same LocalizedContentItemIndexProvider.

@@ -101,7 +101,7 @@ public void Describe(DescribeContext<ContentItem> context)
return new LocalizedContentItemIndex
{
Culture = !partRemoved ? part.Culture.ToLowerInvariant() : null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can reduce the number of checks to one

if (partRemoved)
{
    Culture = LocalizationSet = null;
}
else
{
    Culture = part.Culture.ToLowerInvariant();
    LocalizationSet = part.LocalizationSet;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inside an object initializer so we can't do that. If we want to reduce the number of ifs then from line 101 this has to be broken up with an object initializer, then conditional assignment, then return part, which looks a lot messier.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I saw the object initializer now ;) forget my comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! Thanks for reviewing.

@Piedone Piedone merged commit 574c834 into OrchardCMS:main Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants