diff --git a/uSync8.ContentEdition/Handlers/ContentHandler.cs b/uSync8.ContentEdition/Handlers/ContentHandler.cs index cb4df1c4..b8e43e20 100644 --- a/uSync8.ContentEdition/Handlers/ContentHandler.cs +++ b/uSync8.ContentEdition/Handlers/ContentHandler.cs @@ -1,5 +1,5 @@ using System; - +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Services; @@ -24,6 +24,7 @@ public class ContentHandler : SyncHandlerTreeBase, IS public override string Group => uSyncBackOfficeConstants.Groups.Content; private readonly IContentService contentService; + private bool performDoubleLookup = true; public ContentHandler( IEntityService entityService, @@ -36,6 +37,9 @@ public ContentHandler( : base(entityService, logger, serializer, tracker, checker, syncFileService) { this.contentService = contentService; + + performDoubleLookup = UmbracoVersion.LocalVersion.Major != 8 || UmbracoVersion.LocalVersion.Minor < 4; + } @@ -47,12 +51,19 @@ protected override IContent GetFromService(int id) protected override IContent GetFromService(Guid key) { - // FIX: alpha bug - getby key is not always uptodate - var entity = entityService.Get(key); - if (entity != null) - return contentService.GetById(entity.Id); + if (performDoubleLookup) + { + // FIX: alpha bug - getby key is not always uptodate + var entity = entityService.Get(key); + if (entity != null) + return contentService.GetById(entity.Id); - return null; + return null; + } + else + { + return contentService.GetById(key); + } } protected override IContent GetFromService(string alias) diff --git a/uSync8.ContentEdition/Handlers/MediaHandler.cs b/uSync8.ContentEdition/Handlers/MediaHandler.cs index 9569605d..c4f8e789 100644 --- a/uSync8.ContentEdition/Handlers/MediaHandler.cs +++ b/uSync8.ContentEdition/Handlers/MediaHandler.cs @@ -1,5 +1,5 @@ using System; - +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Services; @@ -25,6 +25,8 @@ public class MediaHandler : SyncHandlerTreeBase, ISyncHan private readonly IMediaService mediaService; + private readonly bool performDoubleLookup; + public MediaHandler( IEntityService entityService, IProfilingLogger logger, @@ -36,6 +38,8 @@ public MediaHandler( : base(entityService, logger, serializer, tracker, checker, syncFileService) { this.mediaService = mediaService; + performDoubleLookup = UmbracoVersion.LocalVersion.Major != 8 || UmbracoVersion.LocalVersion.Minor < 4; + } protected override void DeleteViaService(IMedia item) @@ -46,10 +50,17 @@ protected override IMedia GetFromService(int id) protected override IMedia GetFromService(Guid key) { - // FIX: alpha bug - getby key is not always uptodate - var entity = entityService.Get(key); - if (entity != null) - return mediaService.GetById(entity.Id); + if (performDoubleLookup) + { + // fixed v8.4+ by https://github.com/umbraco/Umbraco-CMS/issues/2997 + var entity = entityService.Get(key); + if (entity != null) + return mediaService.GetById(entity.Id); + } + else + { + return mediaService.GetById(key); + } return null; }