Problem/Motivation

Since updating to version 3.0.1, some views are encountering an exception that traces back to ViewsQueryAlter::alterQueryForEntityType.

TypeError: Unsupported operand types: string + int in Drupal\trash\ViewsQueryAlter->alterQueryForEntityType() (line 143 of modules/contrib/trash/src/ViewsQueryAlter.php)

Proposed resolution

In #3415216: Trash shouldn't add "or" filter to the first views filter group, the views query was adjusted so that instead of assuming the WHERE clause should always be added to group 1, it's always made the last group.

However, the array keys for groups can often be strings. In fact, the default value is '1' (1 as a string) -- see \Drupal\views\Plugin\views\filter\FilterPluginBase::defineOptions. So adding 1 to the last group number is subject to a TypeError.

CommentFileSizeAuthor
#2 3417931-2.patch687 bytesmediabounds

Comments

mediabounds created an issue. See original summary.

mediabounds’s picture

Status: Active » Needs review
StatusFileSize
new687 bytes

I believe the fix is as simple as casting the group number to an int. Patch attached.

amateescu’s picture

Status: Needs review » Fixed

Committed to 3.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.