From 88edd3eead6fffb6bc40baf915e016eb860ea104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Thu, 5 Dec 2024 01:16:03 +0100 Subject: [PATCH] Fixing Queried Content Items query validation --- .../Deployment/QueryBasedContentDeploymentSource.cs | 2 +- .../Deployment/QueryBasedContentDeploymentStepDriver.cs | 2 +- .../OrchardCore.Queries/Sql/SqlQueryHandler.cs | 2 -- .../OrchardCore.Search.Lucene/Services/LuceneQueryHandler.cs | 2 -- .../OrchardCore.Queries.Abstractions/Models/Query.cs | 4 ---- .../Services/ElasticsearchQueryHandler.cs | 2 -- 6 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs index 4c768f33de1..b5db5aab755 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs @@ -26,7 +26,7 @@ protected override async Task ProcessAsync(QueryBasedContentDeploymentStep step, return; } - if (!query.CanReturnContentItems || !query.ReturnContentItems) + if (!query.ReturnContentItems) { return; } diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentStepDriver.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentStepDriver.cs index a94672b94da..542c63ed4b9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentStepDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentStepDriver.cs @@ -52,7 +52,7 @@ await context.Updater.TryUpdateModelAsync(queryBasedContentViewModel, Prefix, var query = await _queryManager.GetQueryAsync(queryBasedContentViewModel.QueryName); - if (!query.CanReturnContentItems || !query.ReturnContentItems) + if (!query.ReturnContentItems) { context.Updater.ModelState.AddModelError(Prefix, nameof(step.QueryName), S["Your Query is not returning content items."]); } diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/SqlQueryHandler.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/SqlQueryHandler.cs index b00c732bc94..d44004a9a96 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/SqlQueryHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/SqlQueryHandler.cs @@ -29,8 +29,6 @@ private static Task UpdateQueryAsync(DataQueryContextBase context) context.Query.Put(metadata); }; - context.Query.CanReturnContentItems = true; - return Task.CompletedTask; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQueryHandler.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQueryHandler.cs index 5cc2a869ef7..29aa13104b2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQueryHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQueryHandler.cs @@ -43,8 +43,6 @@ private static Task UpdateQueryAsync(DataQueryContextBase context) context.Query.Put(metadata); } - context.Query.CanReturnContentItems = true; - return Task.CompletedTask; } } diff --git a/src/OrchardCore/OrchardCore.Queries.Abstractions/Models/Query.cs b/src/OrchardCore/OrchardCore.Queries.Abstractions/Models/Query.cs index c1082f9bffa..e194bb2c9f8 100644 --- a/src/OrchardCore/OrchardCore.Queries.Abstractions/Models/Query.cs +++ b/src/OrchardCore/OrchardCore.Queries.Abstractions/Models/Query.cs @@ -1,4 +1,3 @@ -using System.Text.Json.Serialization; using OrchardCore.Entities; namespace OrchardCore.Queries; @@ -24,8 +23,5 @@ public class Query : Entity /// public string Schema { get; set; } - [JsonIgnore] - public bool CanReturnContentItems { get; set; } - public bool ReturnContentItems { get; set; } } diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticsearchQueryHandler.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticsearchQueryHandler.cs index c84e930e3fa..595b3bd924e 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticsearchQueryHandler.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticsearchQueryHandler.cs @@ -43,8 +43,6 @@ private static Task UpdateQueryAsync(DataQueryContextBase context) context.Query.Put(metadata); } - context.Query.CanReturnContentItems = true; - return Task.CompletedTask; } }