From 437855979dcacf1871992675b562f766a67e2398 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 31 May 2018 23:33:52 +1000 Subject: [PATCH 1/4] Fixes passing in the user id for copy operations --- .../Editors/BackOfficeServerVariables.cs | 2 +- src/Umbraco.Web/Editors/ContentController.cs | 6 ++-- src/Umbraco.Web/Editors/LogController.cs | 31 +------------------ src/Umbraco.Web/Security/WebSecurity.cs | 2 +- 4 files changed, 6 insertions(+), 35 deletions(-) diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index 870bb4f3f7..e550083f66 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -199,7 +199,7 @@ namespace Umbraco.Web.Editors }, { "logApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( - controller => controller.GetEntityLog(0)) + controller => controller.GetPagedEntityLog(0, 0, 0, Core.Persistence.DatabaseModelDefinitions.Direction.Ascending, null)) }, { "memberApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 2caa64fc98..2019a87f4d 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -974,7 +974,7 @@ namespace Umbraco.Web.Editors { var toMove = ValidateMoveOrCopy(move); - Services.ContentService.Move(toMove, move.ParentId); + Services.ContentService.Move(toMove, move.ParentId, Security.GetUserId().ResultOr(0)); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(toMove.Path, Encoding.UTF8, "application/json"); @@ -991,7 +991,7 @@ namespace Umbraco.Web.Editors { var toCopy = ValidateMoveOrCopy(copy); - var c = Services.ContentService.Copy(toCopy, copy.ParentId, copy.RelateToOriginal, copy.Recursive, Security.CurrentUser.Id); + var c = Services.ContentService.Copy(toCopy, copy.ParentId, copy.RelateToOriginal, copy.Recursive, Security.GetUserId().ResultOr(0)); var response = Request.CreateResponse(HttpStatusCode.OK); response.Content = new StringContent(c.Path, Encoding.UTF8, "application/json"); @@ -1013,7 +1013,7 @@ namespace Umbraco.Web.Editors if (foundContent == null) HandleContentNotFound(id); - var unpublishResult = Services.ContentService.Unpublish(foundContent, culture: culture, userId: Security.CurrentUser.Id); + var unpublishResult = Services.ContentService.Unpublish(foundContent, culture: culture, userId: Security.GetUserId().ResultOr(0)); var content = MapToDisplay(foundContent, culture); diff --git a/src/Umbraco.Web/Editors/LogController.cs b/src/Umbraco.Web/Editors/LogController.cs index 08a21a9364..fa532c5fce 100644 --- a/src/Umbraco.Web/Editors/LogController.cs +++ b/src/Umbraco.Web/Editors/LogController.cs @@ -50,36 +50,7 @@ namespace Umbraco.Web.Editors Items = MapAvatarsAndNames(mapped) }; } - - [Obsolete("Use GetPagedLog instead")] - public IEnumerable GetEntityLog(int id) - { - long totalRecords; - var result = Services.AuditService.GetPagedItemsByEntity(id, 1, int.MaxValue, out totalRecords); - return Mapper.Map>(result); - } - - //TODO: Move to CurrentUserController? - [Obsolete("Use GetPagedCurrentUserLog instead")] - public IEnumerable GetCurrentUserLog(AuditType logType, DateTime? sinceDate) - { - long totalRecords; - var dateQuery = sinceDate.HasValue ? SqlContext.Query().Where(x => x.CreateDate >= sinceDate) : null; - var userId = Security.GetUserId().ResultOr(0); - var result = Services.AuditService.GetPagedItemsByUser(userId, 1, int.MaxValue, out totalRecords, auditTypeFilter: new[] {logType},customFilter: dateQuery); - return Mapper.Map>(result); - } - - [Obsolete("Use GetPagedLog instead")] - public IEnumerable GetLog(AuditType logType, DateTime? sinceDate) - { - if (sinceDate == null) - sinceDate = DateTime.Now.Subtract(new TimeSpan(7, 0, 0, 0, 0)); - - return Mapper.Map>( - Services.AuditService.GetLogs(logType, sinceDate.Value)); - } - + private IEnumerable MapAvatarsAndNames(IEnumerable items) { var userIds = items.Select(x => x.UserId).ToArray(); diff --git a/src/Umbraco.Web/Security/WebSecurity.cs b/src/Umbraco.Web/Security/WebSecurity.cs index ad0c5781a3..5de163b638 100644 --- a/src/Umbraco.Web/Security/WebSecurity.cs +++ b/src/Umbraco.Web/Security/WebSecurity.cs @@ -175,7 +175,7 @@ namespace Umbraco.Web.Security } /// - /// Gets the currnet user's id. + /// Gets the current user's id. /// /// public virtual Attempt GetUserId() From 79f95f4243bb5ef77f904454a3de107b7de90d93 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 31 May 2018 23:34:10 +1000 Subject: [PATCH 2/4] fixes removing content item from the cache when it is trashed --- .../PublishedCache/NuCache/PublishedSnapshotService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index 062a696ffc..f1b95278fb 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -1072,8 +1072,8 @@ namespace Umbraco.Web.PublishedCache.NuCache // always refresh the edited data OnRepositoryRefreshed(db, content, false); - // if unpublishing, remove published data from table - if (content.PublishedState == PublishedState.Unpublishing) + // if unpublishing or if it's trashed, remove published data from table + if (content.PublishedState == PublishedState.Unpublishing || content.Trashed) db.Execute("DELETE FROM cmsContentNu WHERE nodeId=@id AND published=1", new { id = content.Id }); // if publishing, refresh the published data From 6ae538d555f73519392307f72ba43da698d57839 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 1 Jun 2018 00:06:59 +1000 Subject: [PATCH 3/4] reverts the fix that doesn't work --- .../PublishedCache/NuCache/PublishedSnapshotService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs index f1b95278fb..062a696ffc 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedSnapshotService.cs @@ -1072,8 +1072,8 @@ namespace Umbraco.Web.PublishedCache.NuCache // always refresh the edited data OnRepositoryRefreshed(db, content, false); - // if unpublishing or if it's trashed, remove published data from table - if (content.PublishedState == PublishedState.Unpublishing || content.Trashed) + // if unpublishing, remove published data from table + if (content.PublishedState == PublishedState.Unpublishing) db.Execute("DELETE FROM cmsContentNu WHERE nodeId=@id AND published=1", new { id = content.Id }); // if publishing, refresh the published data From e6a354876dbac8d3f701e3a7f2b472fdd2fb500f Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 1 Jun 2018 01:00:51 +1000 Subject: [PATCH 4/4] disables ContentFinderByUrlAndTemplate --- src/Umbraco.Web/Routing/ContentFinderByUrlAndTemplate.cs | 1 + src/Umbraco.Web/Runtime/WebRuntimeComponent.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web/Routing/ContentFinderByUrlAndTemplate.cs b/src/Umbraco.Web/Routing/ContentFinderByUrlAndTemplate.cs index 8f507078b3..0b4c02aa8e 100644 --- a/src/Umbraco.Web/Routing/ContentFinderByUrlAndTemplate.cs +++ b/src/Umbraco.Web/Routing/ContentFinderByUrlAndTemplate.cs @@ -12,6 +12,7 @@ namespace Umbraco.Web.Routing /// Provides an implementation of that handles page nice urls and a template. /// /// + /// This finder allows for an odd routing pattern similar to altTemplate, probably only use case is if there is an alternative mime type template and it should be routable by something like "/hello/world/json" where the JSON template is to be used for the "world" page /// Handles /foo/bar/template where /foo/bar is the nice url of a document, and template a template alias. /// If successful, then the template of the document request is also assigned. /// diff --git a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs index 460f881dae..6b9109b7df 100644 --- a/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs +++ b/src/Umbraco.Web/Runtime/WebRuntimeComponent.cs @@ -173,7 +173,7 @@ namespace Umbraco.Web.Runtime .Append() .Append() .Append() - .Append() + //.Append() // disabled, this is an odd finder .Append() .Append();