Unverified Commit 1ab63529 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2884296 by Lendude, anmolgoyal74, kallehauge, Etroid, Nick Hope, dww,...

Issue #2884296 by Lendude, anmolgoyal74, kallehauge, Etroid, Nick Hope, dww, xjm, Dakwamine, wturrell, Rob Holmes, John Pitcairn: Undefined index notice when renaming grouped filter identifiers
parent 8661a5b9
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1347,7 +1347,7 @@ public function convertExposedInput(&$input, $selected_group_id = NULL) {

        // Value can be optional, For example for 'empty' and 'not empty' filters.
        if (isset($this->options['group_info']['group_items'][$selected_group]['value']) && $this->options['group_info']['group_items'][$selected_group]['value'] !== '') {
          $input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
          $input[$this->options['group_info']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
        }
        $this->options['expose']['use_operator'] = TRUE;

@@ -1439,7 +1439,12 @@ public function acceptExposedInput($input) {
    }

    if (!empty($this->options['expose']['identifier'])) {
      if ($this->options['is_grouped']) {
        $value = $input[$this->options['group_info']['identifier']];
      }
      else {
        $value = $input[$this->options['expose']['identifier']];
      }

      // Various ways to check for the absence of non-required input.
      if (empty($this->options['expose']['required'])) {
+33 −0
Original line number Diff line number Diff line
@@ -164,6 +164,39 @@ public function testFilterNotInOperatorGroupedExposedSimple() {
    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
  }

  /**
   * Tests that we can safely change the identifier on a grouped filter.
   */
  public function testFilterGroupedChangedIdentifier() {
    $filters = $this->getGroupedExposedFilters();
    $view = Views::getView('test_view');

    $filters['age']['group_info']['default_group'] = 2;
    $filters['age']['group_info']['identifier'] = 'not-age';
    $view->setDisplay();
    $view->displayHandlers->get('default')->overrideOption('filters', $filters);

    $this->executeView($view);

    $expected_result = [
      [
        'name' => 'John',
        'age' => 25,
      ],
      [
        'name' => 'George',
        'age' => 27,
      ],
      [
        'name' => 'Ringo',
        'age' => 28,
      ],
    ];

    $this->assertCount(3, $view->result);
    $this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
  }

  protected function getGroupedExposedFilters() {
    $filters = [
      'age' => [