diff --git a/src/Umbraco.Web/Editors/EntityController.cs b/src/Umbraco.Web/Editors/EntityController.cs index 5dc13e77cf..55604e0eb9 100644 --- a/src/Umbraco.Web/Editors/EntityController.cs +++ b/src/Umbraco.Web/Editors/EntityController.cs @@ -108,6 +108,8 @@ namespace Umbraco.Web.Editors if (string.IsNullOrEmpty(query)) return Enumerable.Empty(); + //TODO: This uses the internal UmbracoTreeSearcher, this instead should delgate to the ISearchableTree implementation for the type + return ExamineSearch(query, type, searchFrom); } @@ -451,6 +453,9 @@ namespace Umbraco.Web.Editors //the EntityService cannot search members of a certain type, this is currently not supported and would require //quite a bit of plumbing to do in the Services/Repository, we'll revert to a paged search + //TODO: We should really fix this in the EntityService but if we don't we should allow the ISearchableTree for the members controller + // to be used for this search instead of the built in/internal searcher + var searchResult = _treeSearcher.ExamineSearch(filter ?? "", type, pageSize, pageNumber - 1, out long total, id); return new PagedResult(total, pageNumber, pageSize) diff --git a/src/Umbraco.Web/Editors/MacroRenderingController.cs b/src/Umbraco.Web/Editors/MacroRenderingController.cs index 0fd88e2b1e..87887f0cd7 100644 --- a/src/Umbraco.Web/Editors/MacroRenderingController.cs +++ b/src/Umbraco.Web/Editors/MacroRenderingController.cs @@ -102,18 +102,13 @@ namespace Umbraco.Web.Editors private HttpResponseMessage GetMacroResultAsHtml(string macroAlias, int pageId, IDictionary macroParams) { - // note - here we should be using the cache, provided that the preview content is in the cache... - - var doc = _contentService.GetById(pageId); - if (doc == null) - throw new HttpResponseException(HttpStatusCode.NotFound); - var m = _macroService.GetByAlias(macroAlias); if (m == null) throw new HttpResponseException(HttpStatusCode.NotFound); //if it isn't supposed to be rendered in the editor then return an empty string - if (!m.UseInEditor) + //currently we cannot render a macro if the page doesn't yet exist + if (pageId == -1 || !m.UseInEditor) { var response = Request.CreateResponse(); //need to create a specific content result formatted as HTML since this controller has been configured @@ -130,7 +125,7 @@ namespace Umbraco.Web.Editors // When rendering the macro in the backoffice the default setting would be to use the Culture of the logged in user. // Since a Macro might contain thing thats related to the culture of the "IPublishedContent" (ie Dictionary keys) we want // to set the current culture to the culture related to the content item. This is hacky but it works. - var publishedContent = UmbracoContext.ContentCache.GetById(doc.Id); + var publishedContent = UmbracoContext.ContentCache.GetById(pageId); var culture = publishedContent?.GetCulture(); _variationContextAccessor.VariationContext = new VariationContext(); //must have an active variation context! if (culture != null) @@ -143,7 +138,7 @@ namespace Umbraco.Web.Editors //need to create a specific content result formatted as HTML since this controller has been configured //with only json formatters. result.Content = new StringContent( - _componentRenderer.RenderMacro(doc.Id, m.Alias, macroParams).ToString(), + _componentRenderer.RenderMacro(pageId, m.Alias, macroParams).ToString(), Encoding.UTF8, "text/html"); return result; diff --git a/src/Umbraco.Web/Models/PartialViewMacroModel.cs b/src/Umbraco.Web/Models/PartialViewMacroModel.cs index ae4becc7cf..9964877cba 100644 --- a/src/Umbraco.Web/Models/PartialViewMacroModel.cs +++ b/src/Umbraco.Web/Models/PartialViewMacroModel.cs @@ -22,10 +22,10 @@ namespace Umbraco.Web.Models MacroId = macroId; } - public IPublishedContent Content { get; private set; } - public string MacroName { get; private set; } - public string MacroAlias { get; private set; } - public int MacroId { get; private set; } - public IDictionary MacroParameters { get; private set; } + public IPublishedContent Content { get; } + public string MacroName { get; } + public string MacroAlias { get; } + public int MacroId { get; } + public IDictionary MacroParameters { get; } } }