-
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
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -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 and the operation is an INegateOperator, return true, | ||
// since displaying no content type should match any negative comparision on any content type | ||
if (!_contentTypes.Any() && condition.Operation is INegateOperator) | ||
{ | ||
return ValueTask.FromResult(true); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we can say that this will be correct for all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had thought about that. I was originally thinking I only wanted to do that for negative comparisons, but you're right, that should return the expected result (false) for the other comparisons as well. I'll go ahead and make that change. |
||
|
||
foreach (var contentType in _contentTypes) | ||
{ | ||
if (operatorComparer.Compare(condition.Operation, contentType, condition.Value)) | ||
|
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.