Add remove_invalid_terms

pull/3713/head
Isaac Connor 2023-05-23 16:53:52 -04:00
parent 20b7624da0
commit d4a4bd6c8e
1 changed files with 12 additions and 1 deletions

View File

@ -387,7 +387,7 @@ class Filter extends ZM_Object {
Debug("Term " .$term['attr'] . ' is not valid');
continue;
}
if ( !empty($term['cnj']) ) {
if ( $i>0 and !empty($term['cnj']) ) {
while ( true ) {
if ( !count($postfixStack) ) {
$postfixStack[] = array('type'=>'cnj', 'value'=>$term['cnj'], 'sqlValue'=>$term['cnj']);
@ -1191,5 +1191,16 @@ class Filter extends ZM_Object {
$this->terms($new_terms);
}
public function remove_invalid_terms() {
$new_terms = [];
$old_terms = $this->terms();
foreach ($old_terms as $term) {
$Term = new FilterTerm($this, $term);
if ($Term->valid())
$new_terms[] = $term;
}
$this->terms($new_terms);
}
} # end class Filter
?>