From 704b3b2a8032ebbd16a89f7b7191175f4dbc3109 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 24 May 2023 18:30:33 -0400 Subject: [PATCH] Handle missing cnj on terms --- web/includes/Filter.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/web/includes/Filter.php b/web/includes/Filter.php index 245426793..6287c0e17 100644 --- a/web/includes/Filter.php +++ b/web/includes/Filter.php @@ -53,7 +53,11 @@ class Filter extends ZM_Object { $this->_sql = ''; foreach ( $this->FilterTerms() as $term ) { if ($term->valid()) { - if (!$this->_sql and $term->cnj) unset($term->cnj); + if (!$this->_sql) { + if ($term->cnj) unset($term->cnj); + } else { + if (!$term->cnj) $term->cnj = 'and'; + } $this->_sql .= $term->sql(); } else { Debug('Term is not valid '.$term->to_string()); @@ -694,11 +698,6 @@ class Filter extends ZM_Object { else if ( $position < 0 ) $position = 0; - if ( $term && ($position == 0) ) { - # if only 1 term, don't need AND or OR - unset($term['cnj']); - } - array_splice($terms, $position, 0, array($term ? $term : array())); $this->terms($terms);