I am having the same issue with views and explosed multiple selection filters as mentioned here: https://www.drupal.org/node/2315365

I changed the following line in \Drupal\views\Plugin\views\display\DisplayPluginBase:2172
$exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL;
to
$exposed_input = $view->getExposedInput();

This also fixed the issue. Could this be applied to Drupal 8 core?

Issue fork drupal-2865401

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

yassin.barrani created an issue. See original summary.

yassin.barrani’s picture

Issue summary: View changes
yassin.barrani’s picture

Issue summary: View changes
yassin.barrani’s picture

I made a patch for version 8.2.x and 8.3.x

yassin.barrani’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

d.novikov’s picture

Using exposed_raw_input really breaks pager links for Date and Datetime fields.

#4 for 8.3.x cleanly applies to 8.6.2 and works fine for me.

heddn’s picture

Status: Needs review » Reviewed & tested by the community

This fixes the issue for me as well. Without the patch, views with data filters in them resulted in the pager rendering an empty result set.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

In order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:

  1. https://www.drupal.org/docs/8/testing
  2. https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.7.x

Also there's quite a lot of use of $view->exposed_raw_input around - when is it right to use it? Changing this in the base class feels like it could have quite wide impacts.

The docs on ViewExecutable don't really help...

  /**
   * An array of input values from exposed forms.
   *
   * @var array
   */
  protected $exposed_input = [];

  /**
   * Exposed widget input directly from the $form_state->getValues().
   *
   * @var array
   */
  public $exposed_raw_input = [];

  /**
   * Figures out what the exposed input for this view is.
   *
   * They will be taken from \Drupal::request()->query or from
   * something previously set on the view.
   *
   * @return string[]
   *   An array containing the exposed input values keyed by the filter and sort
   *   name.
   *
   * @see self::setExposedInput()
   */
  public function getExposedInput() {
berdir’s picture

Just did run into this as well.

I also found #1802666: Try to understand the difference between the different exposed input variables., which indicates that not even @dawehner knows what all those different properties are for :) The fun part seems to be that exposed_input actually seems to be more "raw" than exposed_raw_input, which contains processed form values, so things like date objects, while exposed_input is the actual "raw" request data: $this->exposed_input = \Drupal::request()->query->all() (which AFAIK again relies on some trickery in \Drupal\views\Controller\ViewAjaxController to be populated in POST requests)

#2865401: Views pager is using exposed_raw_input instead of exposed_input is also a duplicate of this.

berdir’s picture

I had a look at writing a test for this, but the patch to use date form elements is still not committed and without that, you can't really break this, at least not with date filters that are in core. So we have a bit of a chicken/egg problem with #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter, that would introduce this bug, but we can't commit the fix without test coverage that requires that other issue :)

I also had a look at reproducing it with an entity_autocomplete form element that has entity objects as the value. But in manual testing, I wasn't successful, the raw value is the ID, with \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid at least. There's a *lot* of processing/validating input going on there, possibly exactly to work around this behavior.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new2.77 KB

For reference, this is the test that I created using the current date exposed filter, but that obviously works fine as long as it is only a simple textfield.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

bkosborne’s picture

bkosborne’s picture

Ran into this as well with an exposed date field. Also using the patch from #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

hardik_patel_12’s picture

StatusFileSize
new2.76 KB

Re-rolling patch against 8.9.x-dev , kindly review a patch.

ckaotik’s picture

Status: Needs review » Needs work

@Hardik_Patel_12 The patch only includes the tests, it's missing the actual fix. Berdir's was a "test-only" patch :)

ayushmishra206’s picture

Status: Needs work » Needs review
StatusFileSize
new3.49 KB

Rerolled the patch with both fix and the test. Please review. Thanks.

Status: Needs review » Needs work

The last submitted patch, 21: 2865401-21.patch, failed testing. View results

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nicrodgers’s picture

Version: 9.2.x-dev » 9.3.x-dev
Issue tags: +Needs reroll

Needs re-roll

ankithashetty’s picture

Issue tags: -Needs reroll
StatusFileSize
new3.46 KB
new1.61 KB

Rerolled patch in #21, thanks!

dxvargas’s picture

StatusFileSize
new4.46 KB

Patch to fix the tests failing in #25:
# Avoid using Drupal\Tests\UiHelperTrait::drupalPostForm(), use drupalGet() and submitForm() instead.
# Remove an empty URL parameter that is not used anymore.

dxvargas’s picture

Status: Needs work » Needs review
muratk’s picture

Status: Needs review » Reviewed & tested by the community

It worked for us. Thanks a mil.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: 2865401-26.patch, failed testing. View results

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

berdir’s picture

Version: 9.5.x-dev » 10.1.x-dev
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new4.32 KB
new2.26 KB

Rerolled for 9.5 and later (hopefully), updating the tests to work again, looks like classes and also timezone handing changed.

Tests still pass without the fix, see #13/#14, but one option would be to get this committed, then we have test coverage once that issue lands?

lendude’s picture

Status: Needs review » Reviewed & tested by the community

+1 for just adding the coverage here to avoid the chicken/egg problem. The test might not prove the bug, but it does give more confidence that we aren't breaking anything.

+++ b/core/modules/views/tests/src/FunctionalJavascript/PaginationAJAXTest.php
@@ -99,7 +99,7 @@ public function testBasicPagination() {
     // Test that no unwanted parameters are added to the URL.
-    $this->assertEquals('?status=All&type=All&langcode=All&items_per_page=5&order=changed&sort=asc&title=&page=2', $link->getAttribute('href'));
+    $this->assertEquals('?status=All&type=All&langcode=All&items_per_page=5&order=changed&sort=asc&page=2', $link->getAttribute('href'));

Sorta gave me pause, since this removes more unwanted parameters, so how come this wasn't removed before? Since it's empty, it looks ok, but still an unexpected side effect I think?

kunal_sahu made their first commit to this issue’s fork.

kunal_sahu’s picture

Hi I have created a MR . Please Merge . Thanks

quietone’s picture

@kunal_sahu, I am removing credit per How is credit granted for Drupal core issues.

berdir’s picture

> Sorta gave me pause, since this removes more unwanted parameters, so how come this wasn't removed before? Since it's empty, it looks ok, but still an unexpected side effect I think?

Yeah, looks like the different kinds of exposed input things handle empty parameters differently, I think that's an acceptable change and based on you setting it to RTBC, I assume you agree :)

alexpott’s picture

Version: 10.1.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed a487817dbe to 10.1.x and 9041793c01 to 10.0.x. Committed 3664a3d and pushed to 9.5.x. Thanks!

  • alexpott committed a487817d on 10.1.x
    Issue #2865401 by Berdir, yassin.barrani, ankithashetty, dxvargas,...

  • alexpott committed 9041793c on 10.0.x
    Issue #2865401 by Berdir, yassin.barrani, ankithashetty, dxvargas,...

  • alexpott committed 3664a3d4 on 9.5.x
    Issue #2865401 by Berdir, yassin.barrani, ankithashetty, dxvargas,...
dxvargas’s picture

Version: 9.5.x-dev » 10.1.x-dev
Status: Fixed » Reviewed & tested by the community

The tests are now fixed in #32, good!
For the rest, it is the same fix as before (#25), that was already reviewed by the community.
Let's move back the issue to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

@dxvargas the patch committed from #32 includes the fix as was.

luenemann’s picture

Version: 10.1.x-dev » 9.5.x-dev

Status: Fixed » Closed (fixed)

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