TypeError: strpos(): Argument #1 ($haystack) must be of type string in line 141 of ViewsQueryAlter.php

Created on 17 February 2025, 2 months ago

Problem/Motivation

The module tries to find out whether any filter (normal or conditional filter) filters by any delete column. In case it does opt out of adding a specific delete column.

To do so it loops over all conditions in the current views query and compares the name of the conditions field with the name of the deleted column/table. See line 141 of ViewsQueryAlter.php.
Unfortunately the field is not always a string but may also be a ConditionInterface. This leads to the error:
TypeError: strpos(): Argument #1 ($haystack) must be of type string, Drupal\Core\Database\Query\Condition given in strpos() (line 141 of modules/contrib/trash/src/ViewsQueryAlter.php).

Steps to reproduce

Add a custom query alter to the views query and add a query condition for a field.

Proposed resolution

Test if $condition['field'] is a string before using strpos().

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany stborchert

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024