When filter value is falsey, irrelevant warnings written to logs

Created on 3 July 2023, 12 months ago

Problem/Motivation

When a filter criterion is NULL, zero, or the empty string, FilterBuilder logs a warning for "Invalid condition." Let's say that we have a field on nodes called "field_archived", and we want to only return nodes that have a value of zero or NULL on this field. Because the FilterBuilder is validating the condition by checking for a non-falsey value, it will incorrectly flag this condition as invalid (even though the condition will still be applied).

Steps to reproduce

  1. Create a checkbox field called field_archived on a content-type. The checkbox should be backed by a value of '1'.
  2. Configure a search to filter on this field, returning only nodes in which this checkbox is unchecked.
  3. With dblog enabled, run the search.
  4. Observe that dblog has logged a message saying either Invalid condition field_archived = '0' or Invalid condition field_archived = NULL

Proposed resolution

In FilterBuilder::buildFilters(), do not check $condition->getValue() for falsiness when validating the condition.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States daniel_j

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024