Problem/Motivation
Site log is spammed with the next warning:
Invalid condition field_category = NULL
Steps to reproduce
Add filter with "empty" condition to any Search Api view.
Looks like it also happens on 0 values of numeric filter.
Proposed resolution
There is the next check:
if (!$condition->getField() || !$condition->getValue() || !$condition->getOperator()) {
// @todo When using views the sort field is coming as a filter and
// messing with this section.
$this->logger->warning("Invalid condition %condition", ['%condition' => $condition]);
}
Which checks for "!$condition->getValue()", but NULL value is valid value for empty filter, same as 0 for numeric one.
I think this condition should be removed.
Comments
Comment #2
dewalt commentedComment #3
hetal.solanki@dewalt
I have review and try to apply patch and it's working for me.
So moving this issue to RTBC
Thank you!!
Comment #6
mparker17The patch looks fine to me, but I'm having trouble reproducing the issue (and if I can reproduce it manually, then I can add a test) with the instructions provided, i.e.:
@dewalt or @hetal.solanki, could either of you add some more details?
Here's what I've tried...
/admin/structure/views/view/test_elasticsearch_index_searchAddbuttonCategory, click theAdd and configure filter criteriabuttonIs empty (NULL)ApplybuttonSavebutton on the view/test-elasticsearch-index-search/admin/reports/dblogInvalid condition category = NULL/admin/structure/views/view/test_elasticsearch_index_searchAnd/Or Rearrangefrom the drop-buttonRemovein the Test entity - mul changed revisions and data table datasource: Category = row, i.e.: to delete the test filter added in the previous testAddbuttonWidth, click theAdd and configure filter criteriabuttonIs equal to, and set Value to0ApplybuttonSavebutton on the view/test-elasticsearch-index-search/admin/reports/dblogInvalid condition category = NULLComment #7
mparker17(whoops, wrong status, I should have changed it to "maintainer needs more info"... when you add more steps to reproduce, please change it back to RTBC)
Comment #8
sokru commentedI guess it might be related by some faulty Search API configuration or source data issue, but on the other hand search_api_opensearch module has this change committed since day 0 https://git.drupalcode.org/project/search_api_opensearch/-/blob/3.x/src/...
Comment #9
vivibdev commentedI don't know how the view made the request.
But when you made a programmatically search_api query, this warning will trigger each time you search contains a condition with a null or false value.
In src/SearchAPI/Query/FilterBuilder.php, the only way to trigger "exists" condition is to have a null value, but this null value triggers a warning earlier.
first the warning :
then the "exists" only if $condition->getValue() is null :
Comment #10
mparker17Moving to needs review so I can take a second look at it.
Comment #11
oulalahakabu commentedhttps://git.drupalcode.org/project/elasticsearch_connector/-/merge_reque... reviewed : works
Comment #12
mparker17I will try to review this again in the near future, but off the top of my head, the merge request still needs tests... There are already some tests for this part of the code in
tests/src/Unit/SearchAPI/Query/FilterBuilderTest.php.Tests ultimately benefit you, because tests ensure that future changes to the module (i.e.: by other contributors) don't cause regressions in the functionality that you rely on! Please let us know if you need help writing tests!
Comment #13
mparker17Briefly checking the status of this issue after releasing 8.0.0-alpha5...
Since we're missing tests, I'm moving this back to "Needs work". Thanks for understanding!
Comment #14
mparker17Apologies; I forgot about this issue and filed a duplicate - #3584210: Irrelevant warnings when filter value is null, where I ported some other changes from search_api_opensearch. I'm going to close this issue as a duplicate of #3584210: Irrelevant warnings when filter value is null and credit everyone who participated in this issue on that one.
Thanks for your patience with me!