From 00f774f2a9f651b75ca5800a2511e42fc85ac3d5 Mon Sep 17 00:00:00 2001 From: Alexey Murz Korepov Date: Wed, 11 Nov 2020 12:37:36 +0300 Subject: [PATCH] Fix Notice: Undefined index: operator in addConditionGroup When executing queries with ConditionGroup, that doesn't contain operator (that is not required), Drupal shows the notice: ``` Notice: Undefined index: operator in Drupal\graphql_search_api\Plugin\GraphQL\Fields\SearchAPISearch->addConditionGroup() (line 172 of web/modules/contrib/graphql_search_api/src/Plugin/GraphQL/Fields/SearchAPISearch.php). ``` Here is fix for this notice. Instead of `if` checking, I use the `??` construction, that must be available in PHP 7.0+ Also `value` may be not required too, so I add `NULL` replacement to it. --- src/Plugin/GraphQL/Fields/SearchAPISearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/GraphQL/Fields/SearchAPISearch.php b/src/Plugin/GraphQL/Fields/SearchAPISearch.php index 23b8148..ace8a02 100644 --- a/src/Plugin/GraphQL/Fields/SearchAPISearch.php +++ b/src/Plugin/GraphQL/Fields/SearchAPISearch.php @@ -169,7 +169,7 @@ private function addConditionGroup($condition_group_arg) { // Loop through all conditions and add them to the Group. foreach ($group['conditions'] as $condition) { - $condition_group->addCondition($condition['name'], $condition['value'], $condition['operator']); + $condition_group->addCondition($condition['name'], $condition['value'] ?? NULL, $condition['operator'] ?? '='); } // Merge the single groups to the condition group.