Problem/Motivation
There is a relationship provided by taxonomy in TermViewsData, labeled as "Content with term - Relate all content tagged with a term." This relationship allows you to find related content by joining from the taxonomy_index table to the node table.
I believe however that it should be joining to the node_field_data table. As at the moment you cannot add fields, filters, etc. relating to the nodes joined to.
What are the steps required to reproduce the bug?
- Install Drupal - Standard profile
- Add some articles with the same tags
- Create a view of content (nodes)
- Add a views relationship to the tag term field
- Add a views relationship to the "Content with term" using the previous relationship.
- Try to add any fields on content - There is no option for selecting the relationship as the views base node is the only node available.
What behavior were you expecting?
I am expecting to be able to add fields,etc for the related content.
What happened instead?
There is no option for the related content.
Proposed resolution
Change the base table for the relationship
Remaining tasks
Change the base table for the relationship
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | 3011013-2-37.patch | 1.63 KB | alexpott |
| #37 | 3011013-2-37.test-only.patch | 1019 bytes | alexpott |
| #36 | 3011013-36.patch | 2.71 KB | alexpott |
| #36 | 34-36-interdiff.txt | 537 bytes | alexpott |
| #34 | 3011013-34.patch | 2.71 KB | alexpott |
Comments
Comment #2
yanniboi commentedAttached patch
Comment #3
yanniboi commentedComment #4
yanniboi commentedComment #5
yanniboi commentedComment #6
bn_code commentedComment #7
bn_code commentedComment #8
joachim commentedInstead of hardcoding, this should call getViewsTableForEntityType(), like in the code that sets up general reference field relationships:
Comment #9
Max1muss commentedHi there, I'm here at the contribution weekend and I'm going to make the suggested changes!
Comment #10
Max1muss commentedAdding tags
Comment #11
takyros commentedNew patch with suggested changes. #ContributionWeekend2019 @mecmartini, @jlbellido
Comment #12
takyros commentedComment #14
joachim commentedThis item's been lost.
These are good changes, but they're technically scope creep!
They're clean-up tasks, rather than bug fixing. I'm nitpicking, yes, but this is an important principle to keep a patch focussed on the issue.
Comment #15
StephanieLuz commentedTested patch from #2. Worked as expected! (Drupal Contrib Weekend!)
Comment #16
jimafisk commentedTested with @StephanieLuz, #2 works! Thanks!
Comment #17
mecmartini commented@joachim I understand your point, we were using as reference the code on CommentViewsData
Anyway here it's the updated patch with suggested changes.
#ContributionWeekend2019 @karma0321 @jlbellido @Max1muss
Comment #19
mecmartini commentedWe mistaked this line:
with this:
It should be the same. Anyway, if needed, we'll upload a new patch to fix it.
Also, since the tests didn't pass, I guess we need to update the failed tests adding the "node" entity type. We'll try to work on it next week.
Comment #20
mecmartini commentedUpdated patch with tests.
Comment #21
mecmartini commentedComment #23
joachim commentedThe test failure might be because this title property is going to change the UI.
Comment #24
psf_ commentedComment #25
mecmartini commented@joachim I don't see any errors in the build, why the testing failed?
About the #23, the issue there is the title field or the fact that we used
$this->t()as value?Comment #26
joachim commented> About the #23, the issue there is the title field or the fact that we used $this->t() as value?
Don't add the title field. That's changing the UI, and not a part of this issue.
Comment #27
mecmartini commentedUpdated patch without the title field.
Comment #28
joachim commentedLooks good. Thanks everyone!
Comment #31
krzysztof domańskiUnrelated test failure. Back to RTBC.
#3035318: `DateFormatter()` assumes 30 days per month, while February only has 28 days. Causes fails in tests.
Comment #33
alexpottDrupal\Tests\taxonomy\Kernel\Views\TaxonomyFieldTidTest needs fixing.
Comment #34
alexpottFixed the test
Comment #36
alexpottLet's not use a deprecated property
Comment #37
alexpottSo given that the base table is not dynamic I don't think we should be using the entity type manager for this. We don't, for example, in \Drupal\file\FileViewsData, book_views_data(), \Drupal\user\UserViewsData. The only time we use the entity type definition to get the base table name is when it is dynamic. That means we don't need to fix the tests which make this change less disruptive for contrib or custom testing.
Also whilst reviewing this I realise we've not update the 'skip base' setting and I think we should.
Also whilst checking the rest of the code base I've discovered that forum has the same problem. We should look to see if there is a similar issue - I've not fixed it here because views based on forum_index are more broken than just this.
Furthermore I think we should add some automated test coverage of this change - which is done in the attached patch.
Comment #40
Gayathri J commented#37 Tested patch works for me. Looks Good!
Comment #41
joachim commentedThat sounds like an RTBC to me!
Comment #44
catchCommitted/pushed to 9.0.x and 8.9.x thanks!
Wondering if there's a theoretical chance that this could break hook_views_query_alter() implementations or similar, so not backporting to 8.8.x for now.
Comment #46
m@ster commentedduplicated https://www.drupal.org/project/drupal/issues/2457999 ?