Skip to content
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

Adjust content type condition to evaluate to true when no content is displayed and the operation for the given condition is a negation to address. Fixes #15452. #15602

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Display.ContentDisplay;
Expand Down Expand Up @@ -43,6 +44,14 @@ public ValueTask<bool> EvaluateAsync(Condition condition)
private ValueTask<bool> EvaluateAsync(ContentTypeCondition condition)
{
var operatorComparer = _operatorResolver.GetOperatorComparer(condition.Operation);

// If no content types are considered, use the empty string as the value to compare against,
// since we still want comparisons such as "Does Not Equal", "Does Not Start With", etc. to evaluate to true in this case.
if (!_contentTypes.Any())
{
return ValueTask.FromResult(operatorComparer.Compare(condition.Operation, string.Empty, condition.Value));
}

foreach (var contentType in _contentTypes)
{
if (operatorComparer.Compare(condition.Operation, contentType, condition.Value))
Expand Down
Loading