Exposed filter values ignored when using batch

Created on 24 November 2023, 7 months ago
Updated 3 January 2024, 6 months ago

Problem/Motivation

Exposed filters when under batch operations are not being applied properly. This leads to issues with modules like views_data_export where exposed filters are applied incorrectly or not at all leading to incorrect result sets. (see 🐛 Batch exporting is broken in Drupal 10.2 Active for more information).

The cause of this issue is a bit convoluted, but was essentially caused by a phpstan fix to dead code that was ported from the D7 version of Views 14 years ago.

In https://git.drupalcode.org/project/drupal/-/commit/66ddcd2abd3ea7e26bde7... we fixed a phpstan error on this dead code. Before this phpstan fix, that if statement was never evaulating to TRUE because of order of operations (see #10)

Tracking down where this code came from - https://git.drupalcode.org/project/drupal/-/tree/a626abb24faa51ac140f737...

That is - when Views was first committed to core 14 years ago.

Funnily enough, the same phpstan style fix was also committed to the D7 version of views after it had been committed to core, in 2020 #3119249: Undefined variable '$batch'

Then in 2021 this issue was opened #3253277: 7.x-3.25 broke batching in VBO which reported the exact same problem as this very issue (VBO batching broken after the fix). The fix there was to remove the code block entirely.

Steps to reproduce

Create a view with a page that lists users, add an exposed filter on combined username and email. Add a views data export display that outputs a csv using batch. Then go to the created page and filter by the username and press the csv export link.

The csv contains all users instead of just the filtered ones.

Proposed resolution

Remove the previously dead condition that is now breaking exposed filters under batch conditions. Dead meaning that before the phpstan fix it was never being run.

Remaining tasks

Commit
Open follow-up to write tests that cover us for future regressions of this same issue?? TBC

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Fixed

Version

10.2

Component
Views 

Last updated 7 minutes ago

Created by

🇸🇮Slovenia Primsi

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024