Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Issue with redirects pages when both language versions of a page are published directly after one another #75

Open
themaf opened this issue Apr 20, 2022 · 1 comment
Assignees

Comments

@themaf
Copy link

themaf commented Apr 20, 2022

Hi!

On our website we import content from another source regularly. When content is imported both language versions of the same page are automatically published back to back with very little time in between. We discovered that when this happens, a redirect-page is erroneously created for the first language version that was published.

In StaticWebInitialization, in the method OnPublishingContent, oldUrl is correct when the first, in our case Swedish, version of the page is published. But when the English version of the same page is published directly after, oldUrl becomes the url of the Swedish version of the page. Because of this, a redirect page is then created for the url to the Swedish page in OnPublishedContent.

We solved this issue on our site by including the language of the published content when getting oldUrl:

private void OnPublishingContent(object sender, ContentEventArgs e)
{
     var isPage = e.Content is PageData;
     if (isPage)
     {
          var content = e.Content as PageData;
          var staticWebService = ServiceLocator.Current.GetInstance<IStaticWebService>();

          var oldUrl = staticWebService.GetPageUrl(new ContentReference(e.Content.ContentLink.ID), content.Language);
          e.Items.Add("StaticWeb-OldUrl", oldUrl);
     }
}
@7h3Rabbit 7h3Rabbit self-assigned this Apr 28, 2022
@7h3Rabbit
Copy link
Owner

Thanks, I will look at it and probably create a regression test for language handling.
I currently have no language setup locally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants