On configure form every entity is selected when user didn't select anything

Created on 21 February 2021, almost 4 years ago
Updated 29 October 2024, 2 months ago

Problem/Motivation

User reports bulk operation affected all items in a view when none were selected.

Steps to reproduce

Create a view with a configurable action.
Navigate to the view page.
Make sure no items are selected and click the action button -> correctly results in "No items selected" message.
Select at least one item and click the action.
In the action configuration form click BROWSER BACK button
Back in the view page unselect any selected items.
Click the action button again -> shows the action configuration form with a message saying X items selected (all in the view).
Click the action configuration form, click Apply -> The action is applied to all items in the view even though none were selected.

Proposed resolution

Fix the view validation to correctly detect when none selected.

🐛 Bug report
Status

Needs work

Version

4.3

Component

Core

Created by

🇬🇧United Kingdom hughworm

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada tame4tex

    I have been able to replicate this bug on version 4.3.1.

    In our instance, we had custom functionality that added a hidden element to the Views Exposed Form that was unique for each new form build.

    Here is the workflow of the cause of the bug:

    1. When the VBO form was submitted again after returning via the browser back button, the exposed form input had changed, triggering $this->tempStoreData['list'] to be cleared in ViewsBulkOperationsBulkForm::updateTempstoreData().
    2. Then in ViewsBulkOperationsBulkForm::viewsFormSubmit() because the selected key was not in $this->tempStoreData['bulk_form_keys'] nothing got re-added to $this->tempStoreData['list'].
    3. Then finally in ViewsBulkOperationsActionProcessor::executeProcessing() because $data['list'] is empty it gets set to all view results and ALL view results get processed!!

    If we removed the custom hidden element, the bug didn't occur.

    Even though it is a specific set of circumstances that would trigger the bug, I feel it is a critical issue given that data loss (e.g. with delete node action) or security issues (e.g. with unblock users action) could occur.

    I have been able to create a FunctionalJavascript test locally but it requires the browser to be in non headless mode. Not sure if it will work with Gitlab CI but I will add a MR for this test shortly.

  • Pipeline finished with Success
    2 months ago
    Total: 861s
    #324594
  • Pipeline finished with Success
    2 months ago
    Total: 719s
    #324612
  • Pipeline finished with Failed
    2 months ago
    Total: 382s
    #324624
  • 🇨🇦Canada tame4tex

    So it took some fiddling with the chrome options to get back/forward cache working but the test is now failing as expected.

    https://git.drupalcode.org/issue/views_bulk_operations-3199534/-/pipelin...

    I will take a look at the patch from #2 tomorrow and create a MR with a potential fix.

  • Pipeline finished with Failed
    2 months ago
    Total: 173s
    #325432
  • Pipeline finished with Success
    2 months ago
    Total: 578s
    #325526
  • 🇨🇦Canada tame4tex

    I have added MR !91. This was inspired by on_configure_form_every_entity_is_selected-3199534-02.patch and although it doesn't specifically fix the bug, it prevents the bug from causing unexpected data changes by throwing a validation error when the bug conditions occur.

    The problem with patch #2, apart from needing to be modified to apply to updated code, is it just displays the error message No items selected.. After getting the error, if the user continuously selects options without reloading the page, the same error message will keep appearing. So I updated the error message to provide a link to reload the page , along with helpful info to prevent the problem form occurring in the first place.

    Ideally the code needs to be modified to correctly handle back/forward cache, but I believe that is best served in another issue as it is more complex and will most likely need greater input from @graber.

  • Pipeline finished with Success
    2 months ago
    Total: 178s
    #325532
  • Pipeline finished with Failed
    2 months ago
    Total: 391s
    #327229
  • Pipeline finished with Success
    2 months ago
    Total: 174s
    #327237
  • Pipeline finished with Failed
    2 months ago
    Total: 341s
    #327240
  • Pipeline finished with Success
    2 months ago
    #327243
  • 🇨🇦Canada tame4tex

    Updated the MR to add a a pageshow event listener which will prevent the bug from occurring in the first place. As suggested on https://web.dev/articles/bfcache.

    I still think it is worth the extra measure to keep the validation and sanity check in place "just in case".

Production build 0.71.5 2024