From f4c34ad275b9f68770d52d2527bf87d344d8fb0d Mon Sep 17 00:00:00 2001 From: Serhiy Zakharchenko Date: Mon, 6 Jan 2025 20:20:49 +0000 Subject: [PATCH] Fix nullable left join fatal error #2253 Fix searching for approval status fatal error if view has any joins ( Multiple Forms ). --- .../widgets/search-widget/class-search-widget.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/widgets/search-widget/class-search-widget.php b/includes/widgets/search-widget/class-search-widget.php index d21c7c081..2ec57a2dd 100644 --- a/includes/widgets/search-widget/class-search-widget.php +++ b/includes/widgets/search-widget/class-search-widget.php @@ -1113,12 +1113,22 @@ public function gf_query_filter( &$query, $view, $request ) { ) ); $_tmp_query_parts = $_tmp_query->_introspect(); + + /** + * @var GF_Query_Condition $search_condition + * */ $search_condition = $_tmp_query_parts['where']; if ( empty( $filter['key'] ) && $search_condition->expressions ) { $search_conditions[] = $search_condition; } else { + // If the left condition is empty, it is likely a multiple forms filter. In this case, we should retrieve the search condition from the main form. + if ( ! $search_condition->left && $search_condition->expressions ) { + $search_condition = $search_condition->expressions[0]; + } + $left = $search_condition->left; + // When casting a column value to a certain type (e.g., happens with the Number field), GF_Query_Column is wrapped in a GF_Query_Call class. if ( $left instanceof GF_Query_Call && $left->parameters ) { // Update columns to include the correct alias. @@ -1133,7 +1143,7 @@ public function gf_query_filter( &$query, $view, $request ) { }, $left->parameters ); $left = new GF_Query_Call( $left->function_name, $parameters ); - } else { + } elseif ( $left ) { $alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' ); $left = new GF_Query_Column( $left->field_id, $left->source, $alias ); }