Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

410 not cleared when a page is republished #168

Closed
Myster opened this issue Sep 18, 2017 · 4 comments
Closed

410 not cleared when a page is republished #168

Myster opened this issue Sep 18, 2017 · 4 comments
Labels

Comments

@Myster
Copy link

Myster commented Sep 18, 2017

I'm adding this in case this project gets un-abondoned. :-)
When a page is republished it gets a 410 record.
If republished at a different url (parent renamed) it is not redirected

@Myster
Copy link
Author

Myster commented Sep 18, 2017

I did this in my code (works for me) perhaps should be pulled into the project?

public class ContentTrackerHandler : ApplicationEventHandler
{
	protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
		ApplicationContext applicationContext)
	{
		ContentService.Published += Convert410To301Records;
	}

	private void Convert410To301Records(IPublishingStrategy sender, PublishEventArgs<IContent> args)
	{
		var database = ApplicationContext.Current.DatabaseContext.Database;
		foreach (var item in args.PublishedEntities)
		{
			database.Execute(Sql.Builder
				.Append("UPDATE icUrlTracker " +
					    "SET RedirectHttpCode = 301 " +
					    "WHERE RedirectHttpCode = 410 " +
					    "AND RedirectNodeId = @0", item.Id));
		}
	}
}

@daniel-chenery
Copy link
Collaborator

@Myster Thanks, I'll take a look. If a page exists though, it should never hit the URL Tracker AFAIK. It will only run it's code when a 404 is hit.
I'll confirm this though and make updates if required.

What sort of server is this on? Local, Shared, Azure?

@Myster
Copy link
Author

Myster commented Sep 19, 2017

Local & shared server.
The issue is when you unpublish, then move, then republish

daniel-chenery pushed a commit that referenced this issue Sep 26, 2017
@daniel-chenery
Copy link
Collaborator

Fixed with 3.14

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

No branches or pull requests

2 participants