fix URL redirection creation - was failing when save and save+publish as save creates new URL, which is compared to itself in save+publish (#5036)

This commit is contained in:
Nathan Woulfe
2019-03-23 19:29:46 +10:00
committed by Sebastiaan Janssen
parent da6b541112
commit 4e1634754b

View File

@@ -177,11 +177,13 @@ namespace Umbraco.Web.Routing
// change the IUrlSegmentProvider to support being able to determine if a
// segment is going to change for an entity. See notes in IUrlSegmentProvider.
var oldEntity = ApplicationContext.Current.Services.ContentService.GetById(entity.Id);
if (oldEntity == null) continue;
var oldSegment = oldEntity.GetUrlSegment();
// we want the last published version, not the last saved
// otherwise redirects aren't created if content is saved, with save+publish happening later
var publishedEntity = ApplicationContext.Current.Services.ContentService.GetPublishedVersion(entity.Id);
if (publishedEntity == null) continue;
var publishedSegment = publishedEntity.GetUrlSegment();
var newSegment = entity.GetUrlSegment();
process = oldSegment != newSegment;
process = publishedSegment != newSegment;
}
// skip if no segment change