From d26e8e47f132b1fb210e244735ec755d9d948df7 Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Tue, 14 Jan 2025 17:22:02 +0100 Subject: [PATCH 1/2] #8232: Adding warnings when a Projection Query has an empty Filter Group (#8813) * Projections: Returning empty list of content items instead of every content item when the query has no filters * Better solution to skip processing empty filter groups, instead of returning nothing when there's an empty filter group * Code styling and comments * Code styling in ProjectionPartDriver, QueryPartDriver and ProjectionManager * Reverting functional change to ignore empty filter groups * Code styling in AdminController, ProjectionPartDriver and QueryPartDriver * Adding notification when saving a Query or a ProjectionPart to warn about the effect of an empty filter group * Fixing that upgrading Newtonsoft.Json 13.x broke the SpecFlow test execution app --- .../Controllers/AdminController.cs | 23 ++- .../Drivers/ProjectionPartDriver.cs | 184 +++++++++--------- .../Drivers/QueryPartDriver.cs | 28 +-- .../Services/ProjectionManager.cs | 52 ++--- 4 files changed, 149 insertions(+), 138 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs index 01b79f29d..eb9dfc794 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs @@ -1,9 +1,13 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using System.Web.Routing; +using Orchard.ContentManagement; using Orchard.Core.Title.Models; +using Orchard.DisplayManagement; using Orchard.Forms.Services; +using Orchard.Localization; using Orchard.Mvc; using Orchard.Projections.Descriptors.Filter; using Orchard.Projections.Descriptors.Layout; @@ -11,13 +15,9 @@ using Orchard.Projections.Descriptors.SortCriterion; using Orchard.Projections.Models; using Orchard.Projections.Services; using Orchard.Projections.ViewModels; -using Orchard.ContentManagement; -using Orchard.DisplayManagement; -using Orchard.Localization; -using Orchard.UI.Notify; -using System; using Orchard.Settings; using Orchard.UI.Navigation; +using Orchard.UI.Notify; namespace Orchard.Projections.Controllers { [ValidateInput(false)] @@ -84,7 +84,7 @@ namespace Orchard.Projections.Controllers { var model = new AdminIndexViewModel { Queries = results.Select(x => new QueryEntry { - Query = x.As().Record, + Query = x.As().Record, QueryId = x.Id, Name = x.As().Name }).ToList(), @@ -158,16 +158,21 @@ namespace Orchard.Projections.Controllers { Category = f.Category, Type = f.Type, FilterRecordId = filter.Id, - DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext {State = FormParametersHelper.ToDynamic(filter.State)}).Text : filter.Description + DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext { State = FormParametersHelper.ToDynamic(filter.State) }).Text : filter.Description }); } } - filterGroupEntries.Add( new FilterGroupEntry { Id = group.Id, Filters = filterEntries } ); + filterGroupEntries.Add(new FilterGroupEntry { Id = group.Id, Filters = filterEntries }); } viewModel.FilterGroups = filterGroupEntries; + if (viewModel.FilterGroups.Any(group => group.Filters.Count() == 0)) { + _services.Notifier.Warning( + T("This Query has at least one empty filter group, which will cause all content items to be returned, unless the Projection using this Query limits the number of content items displayed.")); + } + #endregion #region Load Sort criterias @@ -185,7 +190,7 @@ namespace Orchard.Projections.Controllers { Category = f.Category, Type = f.Type, SortCriterionRecordId = sortCriterion.Id, - DisplayText = String.IsNullOrWhiteSpace(sortCriterion.Description) ? f.Display(new SortCriterionContext { State = FormParametersHelper.ToDynamic(sortCriterion.State) }).Text : sortCriterion.Description + DisplayText = String.IsNullOrWhiteSpace(sortCriterion.Description) ? f.Display(new SortCriterionContext { State = FormParametersHelper.ToDynamic(sortCriterion.State) }).Text : sortCriterion.Description }); } } diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs index 352368fe6..7230ac7c3 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs @@ -20,10 +20,12 @@ using Orchard.Projections.Settings; using Orchard.Projections.ViewModels; using Orchard.Tokens; using Orchard.UI.Navigation; +using Orchard.UI.Notify; using Orchard.Utility.Extensions; namespace Orchard.Projections.Drivers { public class ProjectionPartDriver : ContentPartDriver { + private readonly IOrchardServices _orchardServices; private readonly IRepository _queryRepository; private readonly IProjectionManagerExtension _projectionManager; private readonly IFeedManager _feedManager; @@ -33,25 +35,25 @@ namespace Orchard.Projections.Drivers { private const string TemplateName = "Parts/ProjectionPart"; public ProjectionPartDriver( - IOrchardServices services, + IOrchardServices orchardServices, IRepository queryRepository, IProjectionManagerExtension projectionManager, IFeedManager feedManager, ITokenizer tokenizer, IDisplayHelperFactory displayHelperFactory, IWorkContextAccessor workContextAccessor) { + _orchardServices = orchardServices; _queryRepository = queryRepository; _projectionManager = projectionManager; _feedManager = feedManager; _tokenizer = tokenizer; _displayHelperFactory = displayHelperFactory; _workContextAccessor = workContextAccessor; + T = NullLocalizer.Instance; - Services = services; } public Localizer T { get; set; } - public IOrchardServices Services { get; set; } protected override string Prefix { get { return "ProjectionPart"; } } @@ -59,7 +61,7 @@ namespace Orchard.Projections.Drivers { var query = part.Record.QueryPartRecord; // retrieving paging parameters - var queryString = Services.WorkContext.HttpContext.Request.QueryString; + var queryString = _orchardServices.WorkContext.HttpContext.Request.QueryString; var pageKey = String.IsNullOrWhiteSpace(part.Record.PagerSuffix) ? "page" : "page-" + part.Record.PagerSuffix; var page = 0; @@ -81,16 +83,14 @@ namespace Orchard.Projections.Drivers { var pageSizeKey = "pageSize" + part.Record.PagerSuffix; if (queryString.AllKeys.Contains(pageSizeKey)) { - int qsPageSize; - - if (Int32.TryParse(queryString[pageSizeKey], out qsPageSize)) { + if (Int32.TryParse(queryString[pageSizeKey], out int qsPageSize)) { if (part.Record.MaxItems == 0 || qsPageSize <= part.Record.MaxItems) { pageSize = qsPageSize; } } } - var pager = new Pager(Services.WorkContext.CurrentSite, page, pageSize); + var pager = new Pager(_orchardServices.WorkContext.CurrentSite, page, pageSize); var pagerShape = shapeHelper.Pager(pager) .ContentPart(part) @@ -107,7 +107,7 @@ namespace Orchard.Projections.Drivers { ContentShape("Parts_ProjectionPart_List", shape => { // generates a link to the RSS feed for this term - var metaData = Services.ContentManager.GetItemMetadata(part.ContentItem); + var metaData = _orchardServices.ContentManager.GetItemMetadata(part.ContentItem); _feedManager.Register(metaData.DisplayText, "rss", new RouteValueDictionary { { "projection", part.Id } }); // execute the query @@ -130,8 +130,8 @@ namespace Orchard.Projections.Drivers { // renders in a standard List shape if no specific layout could be found if (layoutDescriptor == null) { - var list = Services.New.List(); - var contentShapes = contentItems.Select(item => Services.ContentManager.BuildDisplay(item, "Summary")); + var list = _orchardServices.New.List(); + var contentShapes = contentItems.Select(item => _orchardServices.ContentManager.BuildDisplay(item, "Summary")); list.AddRange(contentShapes); return list; @@ -143,7 +143,7 @@ namespace Orchard.Projections.Drivers { var layoutComponents = contentItems.Select( contentItem => { - var contentItemMetadata = Services.ContentManager.GetItemMetadata(contentItem); + var contentItemMetadata = _orchardServices.ContentManager.GetItemMetadata(contentItem); var propertyDescriptors = fieldDescriptors.Select( d => { @@ -156,9 +156,9 @@ namespace Orchard.Projections.Drivers { }); // apply all settings to the field content, wrapping it in a FieldWrapper shape - var properties = Services.New.Properties( + var properties = _orchardServices.New.Properties( Items: propertyDescriptors.Select( - pd => Services.New.PropertyWrapper( + pd => _orchardServices.New.PropertyWrapper( Item: pd.Shape, Property: pd.Property, ContentItem: contentItem, @@ -199,14 +199,14 @@ namespace Orchard.Projections.Drivers { return key; }).Select(x => new { Key = x.Key, Components = x }); - var list = Services.New.List(); + var list = _orchardServices.New.List(); foreach (var group in groups) { var localResult = layoutDescriptor.Render(renderLayoutContext, group.Components); // add the Context to the shape localResult.Context(renderLayoutContext); - list.Add(Services.New.LayoutGroup(Key: new MvcHtmlString(group.Key), List: localResult)); + list.Add(_orchardServices.New.LayoutGroup(Key: new MvcHtmlString(group.Key), List: localResult)); } return list; @@ -223,81 +223,80 @@ namespace Orchard.Projections.Drivers { } protected override DriverResult Editor(ProjectionPart part, dynamic shapeHelper) { - return ContentShape("Parts_ProjectionPart_Edit", - () => { - var model = new ProjectionPartEditViewModel(); + return ContentShape("Parts_ProjectionPart_Edit", () => { + var model = new ProjectionPartEditViewModel(); - // for create read the setting values - var settings = part.TypePartDefinition.Settings.GetModel(); - if (part.Id == 0) { - model = new ProjectionPartEditViewModel { - DisplayPager = settings.DisplayPager, - Items = settings.Items, - Skip = settings.Skip, - PagerSuffix = settings.PagerSuffix, - MaxItems = settings.MaxItems, - QueryLayoutRecordId = settings.QueryLayoutRecordId - }; - } - else { - model = new ProjectionPartEditViewModel { - DisplayPager = part.Record.DisplayPager, - Items = part.Record.Items, - ItemsPerPage = part.Record.ItemsPerPage, - Skip = part.Record.Skip, - PagerSuffix = part.Record.PagerSuffix, - MaxItems = part.Record.MaxItems, - QueryLayoutRecordId = "-1" - }; - // concatenated Query and Layout ids for the view - if (part.Record.QueryPartRecord != null) { - model.QueryLayoutRecordId = part.Record.QueryPartRecord.Id + ";"; - } + // for create read the setting values + var settings = part.TypePartDefinition.Settings.GetModel(); + if (part.Id == 0) { + model = new ProjectionPartEditViewModel { + DisplayPager = settings.DisplayPager, + Items = settings.Items, + Skip = settings.Skip, + PagerSuffix = settings.PagerSuffix, + MaxItems = settings.MaxItems, + QueryLayoutRecordId = settings.QueryLayoutRecordId + }; + } + else { + model = new ProjectionPartEditViewModel { + DisplayPager = part.Record.DisplayPager, + Items = part.Record.Items, + ItemsPerPage = part.Record.ItemsPerPage, + Skip = part.Record.Skip, + PagerSuffix = part.Record.PagerSuffix, + MaxItems = part.Record.MaxItems, + QueryLayoutRecordId = "-1" + }; + // concatenated Query and Layout ids for the view + if (part.Record.QueryPartRecord != null) { + model.QueryLayoutRecordId = part.Record.QueryPartRecord.Id + ";"; + } - if (part.Record.LayoutRecord != null) { - model.QueryLayoutRecordId += part.Record.LayoutRecord.Id.ToString(); - } - else { - model.QueryLayoutRecordId += "-1"; - } - } + if (part.Record.LayoutRecord != null) { + model.QueryLayoutRecordId += part.Record.LayoutRecord.Id.ToString(); + } + else { + model.QueryLayoutRecordId += "-1"; + } + } - model.PartId = part.Id; + model.PartId = part.Id; - // lock fields - model.LockEditingItems = settings.LockEditingItems; - model.LockEditingSkip = settings.LockEditingSkip; - model.LockEditingMaxItems = settings.LockEditingMaxItems; - model.LockEditingPagerSuffix = settings.LockEditingPagerSuffix; - model.LockEditingDisplayPager = settings.LockEditingDisplayPager; + // lock fields + model.LockEditingItems = settings.LockEditingItems; + model.LockEditingSkip = settings.LockEditingSkip; + model.LockEditingMaxItems = settings.LockEditingMaxItems; + model.LockEditingPagerSuffix = settings.LockEditingPagerSuffix; + model.LockEditingDisplayPager = settings.LockEditingDisplayPager; - // populating the list of queries and layouts - var layouts = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).ToList(); - model.QueryRecordEntries = Services.ContentManager.Query().Join().OrderBy(x => x.Title).List() - .Select(x => new QueryRecordEntry { - Id = x.Id, - Name = x.Name, - LayoutRecordEntries = x.Layouts.Select(l => new LayoutRecordEntry { - Id = l.Id, - Description = GetLayoutDescription(layouts, l) - }) - }); + // populating the list of queries and layouts + var layouts = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).ToList(); + model.QueryRecordEntries = _orchardServices.ContentManager.Query().Join().OrderBy(x => x.Title).List() + .Select(x => new QueryRecordEntry { + Id = x.Id, + Name = x.Name, + LayoutRecordEntries = x.Layouts.Select(l => new LayoutRecordEntry { + Id = l.Id, + Description = GetLayoutDescription(layouts, l) + }) + }); - // if any values, use default list of the settings - if (!string.IsNullOrWhiteSpace(settings.FilterQueryRecordId)) { - var filterQueryRecordId = settings.FilterQueryRecordId.Split('&'); - model.QueryRecordIdFilterEntries = filterQueryRecordId - .Select(x => new QueryRecordFilterEntry { - Id = x.Split(';')[0], - LayoutId = x.Split(';')[1] - }); - } - else { - model.QueryRecordIdFilterEntries = new List(); - } + // if any values, use default list of the settings + if (!string.IsNullOrWhiteSpace(settings.FilterQueryRecordId)) { + var filterQueryRecordId = settings.FilterQueryRecordId.Split('&'); + model.QueryRecordIdFilterEntries = filterQueryRecordId + .Select(x => new QueryRecordFilterEntry { + Id = x.Split(';')[0], + LayoutId = x.Split(';')[1] + }); + } + else { + model.QueryRecordIdFilterEntries = new List(); + } - return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix); - }); + return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix); + }); } private static string GetLayoutDescription(IEnumerable layouts, LayoutRecord l) { @@ -313,7 +312,7 @@ namespace Orchard.Projections.Drivers { updater.TryUpdateModel(model, Prefix, null, null); model.PartId = part.Id; - + // check the setting, if it is unlocked, assign the setting value if (settings.LockEditingDisplayPager) { part.Record.DisplayPager = settings.DisplayPager; @@ -356,6 +355,12 @@ namespace Orchard.Projections.Drivers { updater.AddModelError("PagerSuffix", T("Suffix should not contain special characters.")); } + if (model.Items == 0 + && (part.Record.QueryPartRecord?.FilterGroups.Any(group => group.Filters.Count == 0) ?? false)) { + _orchardServices.Notifier.Warning( + T("The selected Query has at least one empty filter group, which causes all content items to be returned. It is recommended to limit the number of content items queried by setting the 'Items to display' field to a non-zero value.")); + } + return Editor(part, shapeHelper); } @@ -376,12 +381,11 @@ namespace Orchard.Projections.Drivers { protected override void ImportCompleted(ProjectionPart part, ImportContentContext context) { // Assign the query only when everything is imported. var query = context.Attribute(part.PartDefinition.Name, "Query"); - if (query != null && context.GetItemFromSession(query).As()!=null) { + if (query != null && context.GetItemFromSession(query).As() != null) { part.Record.QueryPartRecord = context.GetItemFromSession(query).As().Record; var layoutIndex = context.Attribute(part.PartDefinition.Name, "LayoutIndex"); - int layoutIndexValue; if (layoutIndex != null - && Int32.TryParse(layoutIndex, out layoutIndexValue) + && Int32.TryParse(layoutIndex, out int layoutIndexValue) && layoutIndexValue >= 0 && part.Record.QueryPartRecord.Layouts.Count > layoutIndexValue) { part.Record.LayoutRecord = part.Record.QueryPartRecord.Layouts[Int32.Parse(layoutIndex)]; @@ -398,9 +402,9 @@ namespace Orchard.Projections.Drivers { context.Element(part.PartDefinition.Name).SetAttributeValue("DisplayPager", part.Record.DisplayPager); if (part.Record.QueryPartRecord != null) { - var queryPart = Services.ContentManager.Query("Query").Where(x => x.Id == part.Record.QueryPartRecord.Id).List().FirstOrDefault(); + var queryPart = _orchardServices.ContentManager.Query("Query").Where(x => x.Id == part.Record.QueryPartRecord.Id).List().FirstOrDefault(); if (queryPart != null) { - var queryIdentity = Services.ContentManager.GetItemMetadata(queryPart).Identity; + var queryIdentity = _orchardServices.ContentManager.GetItemMetadata(queryPart).Identity; context.Element(part.PartDefinition.Name).SetAttributeValue("Query", queryIdentity.ToString()); context.Element(part.PartDefinition.Name).SetAttributeValue("LayoutIndex", part.Record.QueryPartRecord.Layouts.IndexOf(part.Record.LayoutRecord)); } diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs index f737ee6cc..8024f7704 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs @@ -19,14 +19,16 @@ namespace Orchard.Projections.Drivers { _projectionManager = projectionManager; _formManager = formManager; } + protected override string Prefix { get { return "Query_Part"; } } - protected override DriverResult Editor(QueryPart part, dynamic shapeHelper) { - return Editor(part, null, shapeHelper); - } + + protected override DriverResult Editor(QueryPart part, dynamic shapeHelper) => + Editor(part, null, shapeHelper); + protected override DriverResult Editor(QueryPart part, IUpdateModel updater, dynamic shapeHelper) { var model = new QueryViewModel { VersionScope = part.VersionScope }; if (updater != null) { @@ -34,10 +36,10 @@ namespace Orchard.Projections.Drivers { part.VersionScope = model.VersionScope; } } - return ContentShape("Parts_QueryPart_Edit", - () => { - return shapeHelper.EditorTemplate(TemplateName: "Parts/QueryPart_Edit", Model: model, Prefix: Prefix); - }); + + return ContentShape("Parts_QueryPart_Edit", () => { + return shapeHelper.EditorTemplate(TemplateName: "Parts/QueryPart_Edit", Model: model, Prefix: Prefix); + }); } protected override void Exporting(QueryPart part, ExportContentContext context) { @@ -60,12 +62,12 @@ namespace Orchard.Projections.Drivers { } return new XElement("Filter", - new XAttribute("Category", filter.Category ?? ""), - new XAttribute("Description", filter.Description ?? ""), - new XAttribute("Position", filter.Position), - new XAttribute("State", state ?? ""), - new XAttribute("Type", filter.Type ?? "") - ); + new XAttribute("Category", filter.Category ?? ""), + new XAttribute("Description", filter.Description ?? ""), + new XAttribute("Position", filter.Position), + new XAttribute("State", state ?? ""), + new XAttribute("Type", filter.Type ?? "") + ); }) ) ) diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs b/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs index 6a1a0368e..1fe8f964b 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs @@ -108,19 +108,15 @@ namespace Orchard.Projections.Services { } public int GetCount(int queryId, ContentPart part) { - var queryRecord = _queryRepository.Get(queryId); + var queryRecord = _queryRepository.Get(queryId) ?? throw new ArgumentException("queryId"); - if (queryRecord == null) { - throw new ArgumentException("queryId"); - } - - // prepares tokens + // Prepare tokens. Dictionary tokens = new Dictionary(); if (part != null) { tokens.Add("Content", part.ContentItem); } - // aggregate the result for each group query + // Aggregate the result of each filter group. return GetContentQueries(queryRecord, Enumerable.Empty(), tokens) .Sum(contentQuery => contentQuery.Count()); } @@ -140,13 +136,13 @@ namespace Orchard.Projections.Services { var contentItems = new List(); - // prepares tokens + // Prepare tokens. Dictionary tokens = new Dictionary(); if (part != null) { tokens.Add("Content", part.ContentItem); } - // aggregate the result for each group query + // Aggregate the result of each filter group. foreach (var contentQuery in GetContentQueries(queryRecord, queryRecord.SortCriteria.OrderBy(sc => sc.Position), tokens)) { contentItems.AddRange(contentQuery.Slice(skip, count)); } @@ -155,7 +151,7 @@ namespace Orchard.Projections.Services { return contentItems; } - // re-executing the sorting with the cumulated groups + // Re-executing the sorting on the aggregated results. var ids = contentItems.Select(c => c.Id).ToArray(); if (ids.Length == 0) { @@ -164,7 +160,7 @@ namespace Orchard.Projections.Services { var groupQuery = _contentManager.HqlQuery().Where(alias => alias.Named("ci"), x => x.InG("Id", ids)); - // iterate over each sort criteria to apply the alterations to the query object + // Iterate over each sort criteria to apply the alterations to the query object. foreach (var sortCriterion in queryRecord.SortCriteria.OrderBy(s => s.Position)) { var tokenizedState = _tokenizer.Replace(sortCriterion.State, tokens); var sortCriterionContext = new SortCriterionContext { @@ -177,15 +173,17 @@ namespace Orchard.Projections.Services { string category = sortCriterion.Category; string type = sortCriterion.Type; - // look for the specific filter component - var descriptor = availableSortCriteria.SelectMany(x => x.Descriptors).FirstOrDefault(x => x.Category == category && x.Type == type); + // Find specific sort criterion. + var descriptor = availableSortCriteria + .SelectMany(x => x.Descriptors) + .FirstOrDefault(x => x.Category == category && x.Type == type); - // ignore unfound descriptors + // Skip if not found. if (descriptor == null) { continue; } - // apply alteration + // Apply alteration. descriptor.Sort(sortCriterionContext); groupQuery = sortCriterionContext.Query; @@ -194,7 +192,10 @@ namespace Orchard.Projections.Services { return groupQuery.Slice(skip, count); } - public IEnumerable GetContentQueries(QueryPartRecord queryRecord, IEnumerable sortCriteria, Dictionary tokens) { + public IEnumerable GetContentQueries( + QueryPartRecord queryRecord, + IEnumerable sortCriteria, + Dictionary tokens) { var availableFilters = DescribeFilters().ToList(); var availableSortCriteria = DescribeSortCriteria().ToList(); @@ -204,11 +205,11 @@ namespace Orchard.Projections.Services { var version = queryRecord.VersionScope.ToVersionOptions(); - // pre-executing all groups + // Iterate over each filter group and evaluate the filters. foreach (var group in queryRecord.FilterGroups) { var contentQuery = _contentManager.HqlQuery().ForVersion(version); - // iterate over each filter to apply the alterations to the query object + // Iterate over each filter to apply the alterations to the query object. foreach (var filter in group.Filters) { var tokenizedState = _tokenizer.Replace(filter.State, tokens); var filterContext = new FilterContext { @@ -221,23 +222,23 @@ namespace Orchard.Projections.Services { string category = filter.Category; string type = filter.Type; - // look for the specific filter component + // Find specific filter. var descriptor = availableFilters .SelectMany(x => x.Descriptors) .FirstOrDefault(x => x.Category == category && x.Type == type); - // ignore unfound descriptors + // Skip if not found. if (descriptor == null) { continue; } - // apply alteration + // Apply alteration. descriptor.Filter(filterContext); contentQuery = filterContext.Query; } - // iterate over each sort criteria to apply the alterations to the query object + // Iterate over each sort criteria to apply the alterations to the query object. foreach (var sortCriterion in sortCriteria.OrderBy(s => s.Position)) { var tokenizedState = _tokenizer.Replace(sortCriterion.State, tokens); var sortCriterionContext = new SortCriterionContext { @@ -250,23 +251,22 @@ namespace Orchard.Projections.Services { string category = sortCriterion.Category; string type = sortCriterion.Type; - // look for the specific filter component + // Find specific sort criterion. var descriptor = availableSortCriteria .SelectMany(x => x.Descriptors) .FirstOrDefault(x => x.Category == category && x.Type == type); - // ignore unfound descriptors + // Skip if not found. if (descriptor == null) { continue; } - // apply alteration + // Apply alteration. descriptor.Sort(sortCriterionContext); contentQuery = sortCriterionContext.Query; } - yield return contentQuery; } } From 32c5f1e821bb179818ccd8a31bd4ee2819593c34 Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Fri, 17 Jan 2025 19:22:19 +0100 Subject: [PATCH 2/2] #8822: Upgrading MailKit to 4.9.0 and consolidating all NuGet packages (#8823) * Upgrading MailKit to 4.8.0 and consolidating all NuGet packages * Upgrading MailKit to 4.9.0 and consolidating dependency package versions --- src/Orchard.Core.Tests/App.config | 16 +++++++++ src/Orchard.Specs/App.Config | 20 +++++++++++ src/Orchard.Tests.Modules/App.config | 16 +++++++++ src/Orchard.Web.Tests/app.config | 20 +++++++++++ .../Modules/Markdown/Markdown.csproj | 18 +++++----- src/Orchard.Web/Modules/Markdown/Web.config | 16 +++++++++ .../Modules/Markdown/packages.config | 10 +++--- .../Modules/Orchard.Blogs/Web.config | 16 +++++++++ .../Modules/Orchard.Dashboards/Web.config | 16 +++++++++ .../Modules/Orchard.DesignerTools/Web.config | 16 +++++++++ .../Modules/Orchard.DynamicForms/Web.config | 16 +++++++++ .../Orchard.Email/Orchard.Email.csproj | 34 +++++++++++++++---- .../Modules/Orchard.Email/Web.config | 12 +++++++ .../Modules/Orchard.Email/packages.config | 13 +++++-- .../Modules/Orchard.Layouts/Web.config | 16 +++++++++ .../Modules/Orchard.Search/Web.config | 16 +++++++++ .../Modules/Orchard.Tags/Web.config | 16 +++++++++ .../Modules/Orchard.Widgets/Web.config | 16 +++++++++ src/Orchard.Web/Modules/Upgrade/Web.config | 12 +++++++ src/Orchard.Web/Orchard.Web.csproj | 20 +++++------ src/Orchard.Web/Themes/Web.config | 16 +++++++++ src/Orchard.Web/Web.config | 20 +++++++++++ src/Orchard.Web/packages.config | 10 +++--- 23 files changed, 343 insertions(+), 38 deletions(-) diff --git a/src/Orchard.Core.Tests/App.config b/src/Orchard.Core.Tests/App.config index 6ada2cd01..1f3ed444a 100644 --- a/src/Orchard.Core.Tests/App.config +++ b/src/Orchard.Core.Tests/App.config @@ -26,6 +26,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Specs/App.Config b/src/Orchard.Specs/App.Config index 417d4df69..5ce21ccba 100644 --- a/src/Orchard.Specs/App.Config +++ b/src/Orchard.Specs/App.Config @@ -38,6 +38,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Tests.Modules/App.config b/src/Orchard.Tests.Modules/App.config index 4a4387430..867a6f55b 100644 --- a/src/Orchard.Tests.Modules/App.config +++ b/src/Orchard.Tests.Modules/App.config @@ -42,6 +42,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web.Tests/app.config b/src/Orchard.Web.Tests/app.config index 37b4df731..edbdd0906 100644 --- a/src/Orchard.Web.Tests/app.config +++ b/src/Orchard.Web.Tests/app.config @@ -30,6 +30,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Markdown/Markdown.csproj b/src/Orchard.Web/Modules/Markdown/Markdown.csproj index 21462fb86..d5a4305cc 100644 --- a/src/Orchard.Web/Modules/Markdown/Markdown.csproj +++ b/src/Orchard.Web/Modules/Markdown/Markdown.csproj @@ -62,20 +62,20 @@ ..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - ..\..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - ..\..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - ..\..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll @@ -231,4 +231,4 @@ - + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Markdown/Web.config b/src/Orchard.Web/Modules/Markdown/Web.config index dbacb1007..5a55c6247 100644 --- a/src/Orchard.Web/Modules/Markdown/Web.config +++ b/src/Orchard.Web/Modules/Markdown/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Markdown/packages.config b/src/Orchard.Web/Modules/Markdown/packages.config index e11111c39..1c515e289 100644 --- a/src/Orchard.Web/Modules/Markdown/packages.config +++ b/src/Orchard.Web/Modules/Markdown/packages.config @@ -6,8 +6,8 @@ - - - - - + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Web.config b/src/Orchard.Web/Modules/Orchard.Blogs/Web.config index dbacb1007..5a55c6247 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config b/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config index a043fe512..1ca5a1a65 100644 --- a/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config @@ -69,6 +69,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config b/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config index 6467d9f0d..e218dbb69 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config @@ -69,6 +69,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config b/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config index f791108ba..7b0b8d162 100644 --- a/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config @@ -71,6 +71,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj b/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj index ed6a53a92..7c9775b1e 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj +++ b/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj @@ -55,8 +55,11 @@ ..\..\..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll - - ..\..\..\packages\MailKit.3.1.1\lib\net48\MailKit.dll + + ..\..\..\packages\BouncyCastle.Cryptography.2.5.0\lib\net461\BouncyCastle.Cryptography.dll + + + ..\..\..\packages\MailKit.4.9.0\lib\net48\MailKit.dll ..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\lib\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll @@ -65,23 +68,42 @@ ..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - ..\..\..\packages\MimeKit.3.1.1\lib\net48\MimeKit.dll + + ..\..\..\packages\MimeKit.4.9.0\lib\net48\MimeKit.dll ..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - ..\..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll False + + ..\..\..\packages\System.Formats.Asn1.8.0.1\lib\net462\System.Formats.Asn1.dll + + + ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + + + ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + + ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + ..\..\..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll + + + ..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + diff --git a/src/Orchard.Web/Modules/Orchard.Email/Web.config b/src/Orchard.Web/Modules/Orchard.Email/Web.config index 975f0c223..dc1b9f756 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Email/Web.config @@ -69,6 +69,18 @@ + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Email/packages.config b/src/Orchard.Web/Modules/Orchard.Email/packages.config index 58191e638..0589304a6 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/packages.config +++ b/src/Orchard.Web/Modules/Orchard.Email/packages.config @@ -1,13 +1,20 @@  - + + - + - + + + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Web.config b/src/Orchard.Web/Modules/Orchard.Layouts/Web.config index 13faf444e..390cce3a8 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Web.config @@ -69,6 +69,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Search/Web.config b/src/Orchard.Web/Modules/Orchard.Search/Web.config index dbacb1007..5a55c6247 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Search/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Web.config b/src/Orchard.Web/Modules/Orchard.Tags/Web.config index dbacb1007..5a55c6247 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Tags/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Web.config b/src/Orchard.Web/Modules/Orchard.Widgets/Web.config index dbacb1007..5a55c6247 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Upgrade/Web.config b/src/Orchard.Web/Modules/Upgrade/Web.config index 27dd9de80..fa2449687 100644 --- a/src/Orchard.Web/Modules/Upgrade/Web.config +++ b/src/Orchard.Web/Modules/Upgrade/Web.config @@ -70,6 +70,18 @@ + + + + + + + + + + + + diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index cf56d91b1..0707cfd68 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -88,8 +88,8 @@ ..\packages\Owin.1.0\lib\net40\Owin.dll - - ..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll + + ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll @@ -100,19 +100,19 @@ ..\..\lib\sqlce\System.Data.SqlServerCe.dll True - - ..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll + + ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - ..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + ..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll diff --git a/src/Orchard.Web/Themes/Web.config b/src/Orchard.Web/Themes/Web.config index f09510e13..08cb067f3 100644 --- a/src/Orchard.Web/Themes/Web.config +++ b/src/Orchard.Web/Themes/Web.config @@ -91,6 +91,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Web.config b/src/Orchard.Web/Web.config index 913c4f04d..de4c277a8 100644 --- a/src/Orchard.Web/Web.config +++ b/src/Orchard.Web/Web.config @@ -227,6 +227,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/packages.config b/src/Orchard.Web/packages.config index 750cc0a62..5b268d7c2 100644 --- a/src/Orchard.Web/packages.config +++ b/src/Orchard.Web/packages.config @@ -14,10 +14,10 @@ - - - - - + + + + + \ No newline at end of file