Skip to content
Snippets Groups Projects
Verified Commit 1c95773f 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

(cherry picked from commit 0dac7cab)
parent 38b8399e
No related branches found
No related tags found
22 merge requests!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9944Issue #3483353: Consider making the createCopy config action optionally fail...,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8597Draft: Issue #3442259 by catch, quietone, dww: Reduce time of Migrate Upgrade tests...,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!8325Update file Sort.php,!8095Expose document root on install,!7930Resolve #3427374 "Taxonomytid viewsargumentdefault plugin",!7627Issue #3439440 by nicxvan, Binoli Lalani, longwave: Remove country support from DateFormatter,!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #148641 passed with warnings
Pipeline: drupal

#148645

    ......@@ -94,6 +94,18 @@ protected function setUp($import_test_views = TRUE, $modules = []): void {
    }
    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([
    'vid' => 'empty_vocabulary',
    'name' => 'Empty Vocabulary',
    ......@@ -371,8 +383,12 @@ public function testFilterGrouping() {
    $field_name = 'taxonomy_tags';
    $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,
    // and 1 node with 2 tagged terms.
    // Create the other tag field itself.
    $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_with_term_1_0 = $this->drupalCreateNode([
    $field_name => [['target_id' => $this->terms[1][0]->id()]],
    ......@@ -387,6 +403,10 @@ public function testFilterGrouping() {
    $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
    // up the second group as an 'OR' group. The first subgroup of the second
    // filter group will vary as follows:
    ......@@ -492,6 +512,45 @@ public function testFilterGrouping() {
    $this->assertSession()->pageTextContainsOnce($node_with_terms_1_0_and_1_1->label());
    $this->assertSession()->pageTextContainsOnce($node_with_term_2_0->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() {
    // query optimization, INNER joins are slightly faster, so use them
    // when we know we can.
    $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';
    }
    $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;
    }
    ......
    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