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

Avoid cloning the AutoroutePart pattern in the localized content #15810

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't fix the issue:

2024-05-02_20h06_41.mp4

Copy link
Member Author

@hishamco hishamco May 2, 2024

Choose a reason for hiding this comment

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

Please try it without your last suggestion - Using Alter - I'm 100% percentage sure it was working as expected

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 weird I don't know why the

context.ContentItem.Alter<AutoroutePart>(p => p.Path = null);

doesn't work as expected here?!! Do you have any idea or shall I revert the last change

Copy link
Member

Choose a reason for hiding this comment

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

That's good, but please make it work in a statically typed way. We don't need dynamic for this.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know, sorry, I'd also need to get into debugging this to figure it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

We might need to revise this, using CloningAsync() might resolve the issue but not make sense while LocalizingAsync() should be the suited event for that

Copy link
Member

Choose a reason for hiding this comment

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

if that is the case, then call _session.SaveAsync() after calling LocalizingAsync. But honestly, this sounds like a bad idea to me. IContentHandler should be the right event to hook into at that point. LocalizingAsync should not be used to alter the content item.

Copy link
Member Author

Choose a reason for hiding this comment

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

LocalizingAsync should not be used to alter the content item.

For that I alert the autoroute path without using Alter() just to solve the above issue

Copy link
Member

Choose a reason for hiding this comment

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

Can you create a test case for the Alter method to make sure STJ isn't causing a problem? Alter should work.

Copy link
Member Author

@hishamco hishamco May 3, 2024

Choose a reason for hiding this comment

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

This is #15714 a recent PR that I merged, the Alter was working fine

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Task LocalizingAsync(LocalizationContentContext context)
if (context.ContentItem.Has<AutoroutePart>())
{
// Clearing the AutoroutePart path to regenerate the permalink automatically.
context.ContentItem.Content.AutoroutePart.Path = null;
context.ContentItem.Alter<AutoroutePart>(p => p.Path = null);
}

return Task.CompletedTask;
Expand Down