-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add full_text_aspect liquid filter #7357
Conversation
src/OrchardCore.Modules/OrchardCore.Contents/Indexing/FullTextContentIndexHandler.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Contents/Handlers/FullTextAspectContentHandler.cs
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Contents/Liquid/FullTextAspectFilter.cs
Outdated
Show resolved
Hide resolved
Potential stack overflow to fix |
@jtkech might ask you to take a look at this, as I know you did a shape recursion pr a while back. Here I have to use the I also found it possible to stackoverflow a liquid Could not find a way to break it with any of the other helpers. Edited |
Okay, i will take a look this night |
services.AddLiquidFilter<FullTextFilter>("full_text"); | ||
|
||
services.AddScoped<IContentItemRecursionHelper<FullTextFilter>, ContentItemRecursionHelper<FullTextFilter>>(); | ||
services.AddScoped<IContentItemRecursionHelper<BuildDisplayFilter>, ContentItemRecursionHelper<BuildDisplayFilter>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have registered a generic one
services.AddScoped(typeof(IContentItemRecursionHelper<>), typeof(ContentItemRecursionHelper<>));
So that another one could be resolved on demand without having to do another registration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that @jtkech didn't even know about it.
Will do some docs shortly, so will change that then.
{ | ||
if (_contentItemIds.Contains(contentItem.ContentItemId)) | ||
{ | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes i just cache the whole object and contains uses a by ref comparison
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I couldn't because there is too much JObject.ToObject<ContentItem>
which breaks by ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool then
// When {{ Model.ContentItem | shape_build_display | shape_render }} is called prevent recursion. | ||
if (buildDisplayRecursionHelper.IsRecursive(contentItem)) | ||
{ | ||
return new ValueTask<FluidValue>(NilValue.Instance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure here that it can't be called more than once, not necessarily through the same model / shape, but on the same item, this in a given request scope?
Too late, already merged ;) I still did a little review Yes i did some recursions checking, as i remember it was to prevent a shape / model to render itself too many times, by comparing by ref the passed model to the current one, max recursions being equal to 3. The use case is
I still did a little review, the main remark is to register a generic helper
One question, the recursion helper is also used in the |
Tricky @jtkech , in a single request scope if you accidentally call So preventing that. But it is possible you might want to render items twice. I have done that sometimes for a list view and a tile view... But in Razor. Hmm I will think if there is a better way to keep it safe, but not preventing scenarios either. |
@deanmarcussen Yes i meant in the same request scope, so now in the same template context, but from 2 different models / shapes but displaying the same content item, e.g. in 2 different places, yes maybe in 2 display modes. But that's okay for me ;) Otherwise maybe just a max recursion counter with a max recursion value Hmm, one solution would be to also pass to your helper the current |
Fixes #7128
Adds a
full_text_aspect
filter, which can be used in theFullTextSettings
to allow Widgets or Bags items contribute towards the full text search index.Usage