Skip to content
Snippets Groups Projects
Verified Commit 0dac7cab authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1766338 by vasike, John Pitcairn, sagesolutions, jenlampton, ckaotik,...

Issue #1766338 by vasike, John Pitcairn, sagesolutions, jenlampton, ckaotik, andyanderso, SoulReceiver, Krzysztof Domański, liquidcms, smustgrave, luenemann, sorin.eugen, dawehner, xenophyle, Lendude, zebda, pameeela, longwave, alison: Incorrect filter group OR behavior, LEFT JOIN changed to INNER JOIN
parent 6cea3277
No related branches found
No related tags found
27 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #148643 canceled
Pipeline: drupal

#148646

    ...@@ -94,6 +94,18 @@ protected function setUp($import_test_views = TRUE, $modules = []): void { ...@@ -94,6 +94,18 @@ protected function setUp($import_test_views = TRUE, $modules = []): void {
    } }
    ViewTestData::createTestViews(static::class, ['taxonomy_test_views']); ViewTestData::createTestViews(static::class, ['taxonomy_test_views']);
    // Extra taxonomy and terms.
    Vocabulary::create([
    'vid' => 'other_tags',
    'name' => 'Other tags',
    ])->save();
    $this->terms[3][0] = $term = Term::create([
    'vid' => 'tags',
    'name' => "Term 3.0",
    ]);
    $term->save();
    Vocabulary::create([ Vocabulary::create([
    'vid' => 'empty_vocabulary', 'vid' => 'empty_vocabulary',
    'name' => 'Empty Vocabulary', 'name' => 'Empty Vocabulary',
    ...@@ -371,8 +383,12 @@ public function testFilterGrouping() { ...@@ -371,8 +383,12 @@ public function testFilterGrouping() {
    $field_name = 'taxonomy_tags'; $field_name = 'taxonomy_tags';
    $this->createEntityReferenceField('node', $node_type->id(), $field_name, NULL, 'taxonomy_term'); $this->createEntityReferenceField('node', $node_type->id(), $field_name, NULL, 'taxonomy_term');
    // Create 4 nodes: 1 node without any tagging, 2 nodes tagged with 1 term, // Create the other tag field itself.
    // and 1 node with 2 tagged terms. $field_name2 = 'taxonomy_other_tags';
    $this->createEntityReferenceField('node', $node_type->id(), $field_name2, NULL, 'taxonomy_term');
    // Create 5 nodes: 1 node without any tagging, 2 nodes tagged with 1 term,
    // 1 node with 2 tagged terms and 1 with other tags term.
    $node_no_term = $this->drupalCreateNode(); $node_no_term = $this->drupalCreateNode();
    $node_with_term_1_0 = $this->drupalCreateNode([ $node_with_term_1_0 = $this->drupalCreateNode([
    $field_name => [['target_id' => $this->terms[1][0]->id()]], $field_name => [['target_id' => $this->terms[1][0]->id()]],
    ...@@ -387,6 +403,10 @@ public function testFilterGrouping() { ...@@ -387,6 +403,10 @@ public function testFilterGrouping() {
    $field_name => [['target_id' => $this->terms[2][0]->id()]], $field_name => [['target_id' => $this->terms[2][0]->id()]],
    ]); ]);
    $node_with_term_3_0 = $this->drupalCreateNode([
    $field_name2 => [['target_id' => $this->terms[3][0]->id()]],
    ]);
    // Create two groups. The first group contains the published filter and set // Create two groups. The first group contains the published filter and set
    // up the second group as an 'OR' group. The first subgroup of the second // up the second group as an 'OR' group. The first subgroup of the second
    // filter group will vary as follows: // filter group will vary as follows:
    ...@@ -492,6 +512,45 @@ public function testFilterGrouping() { ...@@ -492,6 +512,45 @@ public function testFilterGrouping() {
    $this->assertSession()->pageTextContainsOnce($node_with_terms_1_0_and_1_1->label()); $this->assertSession()->pageTextContainsOnce($node_with_terms_1_0_and_1_1->label());
    $this->assertSession()->pageTextContainsOnce($node_with_term_2_0->label()); $this->assertSession()->pageTextContainsOnce($node_with_term_2_0->label());
    $this->assertSession()->pageTextNotContains($node_no_term->label()); $this->assertSession()->pageTextNotContains($node_no_term->label());
    // Different fields/taxonomies filters/values.
    // Case 5: OR
    // - filter "tid" with terms from tags as "is one of"
    // - filter "taxonomy_other_tags_target_id" with term from other tags
    // as "is one of".
    $view = View::load('test_filter_taxonomy_index_tid');
    $display = &$view->getDisplay('default');
    $display['display_options']['filters']['tid']['value'][0] = $this->terms[1][0]->id();
    $display['display_options']['filters']['tid']['value'][1] = $this->terms[1][1]->id();
    $display['display_options']['filters']['tid']['operator'] = 'or';
    $display['display_options']['filters']['tid']['group'] = 2;
    $display['display_options']['filters']['taxonomy_other_tags_target_id'] = $display['display_options']['filters']['tid'];
    $display['display_options']['filters']['taxonomy_other_tags_target_id']['id'] = 'taxonomy_other_tags_target_id';
    $display['display_options']['filters']['taxonomy_other_tags_target_id']['value'][0] = $this->terms[3][0]->id();
    $display['display_options']['filters']['taxonomy_other_tags_target_id']['operator'] = 'or';
    $display['display_options']['filters']['taxonomy_other_tags_target_id']['group'] = 2;
    $display['display_options']['filters']['taxonomy_other_tags_target_id']['table'] = 'node__taxonomy_other_tags';
    $display['display_options']['filters']['taxonomy_other_tags_target_id']['field'] = 'taxonomy_other_tags_target_id';
    unset($display['display_options']['filters']['tid_2']);
    $display['display_options']['filter_groups'] = [
    'operator' => 'AND',
    'groups' => [
    1 => 'AND',
    2 => 'OR',
    ],
    ];
    $view->save();
    $this->drupalGet('test-filter-taxonomy-index-tid');
    // We expect no nodes tagged with term 1.0 or 1.1. The node tagged with
    // term 3.0 and the untagged node will be shown.
    $this->assertSession()->pageTextContainsOnce($node_with_term_1_0->label());
    // The view does not have DISTINCT query enabled, the node tagged with
    // both 1.0 and 1.1 will appear twice.
    $this->assertSession()->pageTextMatchesCount(2, "/{$node_with_terms_1_0_and_1_1->label()}/");
    $this->assertSession()->pageTextContainsOnce($node_with_term_3_0->label());
    $this->assertSession()->pageTextNotContains($node_with_term_2_0->label());
    $this->assertSession()->pageTextNotContains($node_no_term->label());
    } }
    } }
    ...@@ -181,9 +181,12 @@ public function ensureMyTable() { ...@@ -181,9 +181,12 @@ public function ensureMyTable() {
    // query optimization, INNER joins are slightly faster, so use them // query optimization, INNER joins are slightly faster, so use them
    // when we know we can. // when we know we can.
    $join = $this->getJoin(); $join = $this->getJoin();
    if (isset($join)) { $group = $this->handler->options['group'] ?? FALSE;
    // Only if there is no group with OR operator.
    if (isset($join) && !($group && $this->handler->query->where[$group]['type'] === 'OR')) {
    $join->type = 'INNER'; $join->type = 'INNER';
    } }
    $this->handler->tableAlias = $this->handler->query->ensureTable($this->handler->table, $this->handler->relationship, $join); $this->handler->tableAlias = $this->handler->query->ensureTable($this->handler->table, $this->handler->relationship, $join);
    $this->handler->view->many_to_one_tables[$field] = $this->handler->value; $this->handler->view->many_to_one_tables[$field] = $this->handler->value;
    } }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment