I found this issue when upgrading from 7.x-3.16 to 7.x-3.15

I'm using Better Exposed Filters 7x 3.4

When clicking on any of my checkbox filters (multi choice) , once I've checked on one of the filters options I cannot then untick all of the options for that specific filter.

I've found that the new code for the functionget_exposed_input is at fault. If I use the function from 7.x-3.15 , then things work as they should.

I've had a look at the code itself but do not have a good enough grasp of why the code has changed to work out what the ultimate fix for this would be.

Here's the code from 7.x-3.15

    function get_exposed_input() {
        // Fill our input either from $_GET or from something previously set on the
        // view.
        if (empty($this->exposed_input)) {
            $this->exposed_input = $_GET;
            // unset items that are definitely not our input:
            foreach (array('page', 'q') as $key) {
                if (isset($this->exposed_input[$key])) {
                    unset($this->exposed_input[$key]);
                }
            }

            // If we have no input at all, check for remembered input via session.

            // If filters are not overridden, store the 'remember' settings on the
            // default display. If they are, store them on this display. This way,
            // multiple displays in the same view can share the same filters and
            // remember settings.
            $display_id = ($this->display_handler->is_defaulted('filters')) ? 'default' : $this->current_display;

            if (empty($this->exposed_input) && !empty($_SESSION['views'][$this->name][$display_id])) {
                $this->exposed_input = $_SESSION['views'][$this->name][$display_id];
            }
        }

        return $this->exposed_input;
    }

And this from 7.x-3.16

  function get_exposed_input() {
    if (empty($this->exposed_input)) {
      $this->exposed_input = array();

      // If filters are not overridden, store the 'remember' settings on the
      // default display. If they are, store them on this display. This way,
      // multiple displays in the same view can share the same filters and
      // remember settings.
      $display_id = ($this->display_handler->is_defaulted('filters')) ? 'default' : $this->current_display;

      // Start with remembered input via session.
      if (!empty($_SESSION['views'][$this->name][$display_id])) {
        $this->exposed_input = $_SESSION['views'][$this->name][$display_id];
      }

        $get_url = $_GET;
        // unset items that are definitely not our input:
        foreach (array('page', 'q') as $key) {
            if (isset($get_url[$key])) {
                unset($get_url[$key]);
            }
        }

      // Fetch exposed input values from $_GET. Overwrite if clashing.
      foreach ($get_url as $key => $value) {
        if (!in_array($key, array('page', 'q'))) {
          $this->exposed_input[$key] = $value;
        }
      }
    }

    return $this->exposed_input;
  }

Comments

DeejayM created an issue. See original summary.

wub’s picture

We are also apparently experiencing this bug with the interaction between views and BEF. Thank you for the great analysis, DeejayM!

mistrytheory’s picture

Hi

I took a look into this myself too, based on DeejayM's investigation, and it's a regression of this issue: https://www.drupal.org/node/1881910

Commenting out the below fixes the issue for me:

if (!empty($_SESSION['views'][$this->name][$display_id])) {
        $this->exposed_input = $_SESSION['views'][$this->name][$display_id];
      }

Can someone more experienced take a look please, as I'm not sure if this is needed or not?

MustangGB’s picture

Title: Better exposed filter checkboxes not being able to untick all selections » REGRESSION: Better exposed filter checkboxes not being able to untick all selections
MustangGB’s picture

Priority: Normal » Major
Parent issue: » #2903944: Plan for Views 7.x-3.19 release