empty option validation for views bulk form causing issue when Action Key value 0 in dropdown

Created on 10 November 2023, over 1 year ago
Updated 11 December 2023, over 1 year ago

Problem/Motivation

Bulk Action validation failed on bulk form of view. The action bulk form in the view "Bulk update" field, having entity action options with key value 0,1,2 etc in drop-down. So in code empty() function treat 0 as empty and its failing.

Steps to reproduce

Go to view and add field of bulk update.

Proposed resolution

in code in if condition use strlen() in place of empty().

🐛 Bug report
Status

Closed: cannot reproduce

Version

11.0 🔥

Component
Views 

Last updated 7 minutes ago

Created by

🇮🇳India kkalaskar Pune

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

  • Issue created by @kkalaskar
  • 🇮🇳India kkalaskar Pune

    Created patch with following change

    Existing :-

       $action = $form_state->getValue('action');
        if (empty($action)) {
          $form_state->setErrorByName('', $this->emptyActionMessage());
        }
    
    

    Updated :-

        $action = $form_state->getValue('action');
        if (strlen($action) === 0) {
          $form_state->setErrorByName('', $this->emptyActionMessage());
        }
    
  • Status changed to Needs review over 1 year ago
  • This doesn't seem to be a usability bug, just a bug. I am removing that tag.

  • last update over 1 year ago
    29,681 pass, 2 fail
  • 🇺🇸United States smustgrave

    Moving to 11.x development branch.

    Thanks for reporting, we will also need a test case that shows this issue.

  • Status changed to Needs work over 1 year ago
  • Status changed to Closed: cannot reproduce over 1 year ago
  • 🇳🇱Netherlands Lendude Amsterdam

    The screenshot shows the Media Bulk update plugin and the actions appear to be from a Files bulk plugin in the other screenshot?

    The actions in the screenshot do not appear to come from Drupal Core. The media Bulk update plugin uses string keys as you would expect here.

    If I'm overlooking something please feel free to re-open this and add steps to reproduce this with just Drupal core.

Production build 0.71.5 2024