Problem/Motivation
Create a new view of "Content revisions", open the "Advanced" section, and Add a relationship.
Two of the options have title "Content", category "Content revision", and no description:

The two options are different: one joins on the content ID (nid) and the other joins on the revision ID (vid).
Proposed resolution
Add descriptions that distinguish between the two options:
- Joining on the
nid always gives some result, so add the description "Content associated to this revision".
- Joining on the
vid gives NULL except for the current revision, so add the description "Associated content for the current revision, NULL otherwise".
Remaining tasks
- Review (wordsmith) the new text.
User interface changes
Change the "Add relationships" dialogue.

API changes
None
Data model changes
None
Comments
Comment #2
benjifisherHere is one suggestion for the wording:
I feel pretty strongly that this is better than nothing, but there is room for improvement.
I want to keep the text short. I think any site builder who gets this far (adding a relationship to a view of content revisions) should already be pretty familiar with Drupal, so I think it is right to favor accuracy at the expense of some simplicity. But I did not go all the way and refer to "content ID" and "revision ID".
The patch affects code in the node module, so maybe I am wrong to assign this issue to the
views.modulecomponent. On the other hand, I see the option "node system" but not "node.module". Maybe I should just classify it under "user interface text" (done).I am adding #2844820: Improve Views revision integration for all revisionable entities as a related issue, in case this functionality ever gets extended to all revisionable entities.
I am adding #1832858: Revamp descriptions of items in handler listings as a related issue. Maybe we should make that the parent of the current issue.
Comment #4
benjifisherComment #5
marcoscanoManually tested, and can confirm that:
- The issue exists
- The patch applies cleanly to 8.5.x HEAD
- The patch solves the issue and shows the two above mentioned descriptions.
The only thing I see is that I'm not 100% sure I can tell the difference between both items by just reading their descriptions, but that may be due to my lack of knowledge about this topic...
Comment #6
benjifisherThanks for the review!
I will add a little more information to the issue description.
As I pointed out on #2769289: Can't show 'revision author' on views of type 'Content', one way to get a view of current revisions is to join on the
vidand make it an inner join by checking "Require this relationship".Comment #7
benjifisher@xjm points out that this needs tests. I am also going to look (again) for a duplicate issue.
Comment #8
benjifisherComment #9
benjifisherI am happy to get help with wordsmithing the descriptions, but I do not think that every single string needs attention from the UX team, so I am removing the "Needs usability review" tag that I added when I updated the IS.
Test added, so I am removing that tag.
This is my first time writing a JS test from scratch, so I am not sure what the testbot will say.
Comment #11
benjifisherAs I said, I need practice writing these tests.
Comment #13
benjifisherTry again.
Comment #15
benjifisherMaking progress.
Comment #17
benjifisherand again
Comment #19
benjifisherTry a different selector to open the "Advanced" section of the Views edit page.
Comment #21
benjifisherI recently switched to Lando/Docker for my local sites. I was not able to run the test locally until I figured out how to get pahntomjs installed on the container.
In a javascript test, I expected the machine name to be filled in automatically when I enter the human-readable name. This did not happen, so I had to do this:
Comment #24
marcoscanoI'm not sure it is really necessary to be so cautious about waiting for the elements before clicking on them (at least I don't remember having seen this so often in other tests). I know however that we've experienced some random failures in other tests recently, so I assume this comes from those experiences... :)
Otherwise looks good to me!
Comment #25
benjifisherExactly: failure to wait seems to be the cause of intermittent failures. For example, I worked on #2934997: Intermittent failure in MediaUiJavascriptTest, where that was the problem.
Comment #26
mpdonadioReviewing this as part of mentoring.
Comment #27
schiavone commentedReviewed in the UI. Before patch the descriptions are empty. After patch I see descriptions for relationships as described above.
Automated testing failed looking for first description on the expected line.
Comment #28
schiavone commentedComment #29
dawehnerIs there a way to at least don't make this javascript tests? This at max needs a browser, though I'm wondering whether we should rather explicitely test the data definition, because this is where the problem is.
Comment #30
benjifisher@dawehner:
The point of the patch is to make useful interface text show up, so I think we really need a functional test for this. Besides, that is the sort of test that @xjm requested (off line).
Thanks for suggesting a non-JS test. I found NodeRevisionWizardTest.php, which already sets up a test view of node revisions. There are a few options:
setUp()and a test).The attached patch implements the middle option. (My local git repo has a commit implementing the first option, so I can easily produce a patch for that.) I wonder whether I should rename the test class, since it now tests more than the wizard.
While refactoring the tests, I made a few changes that might be considered out of scope:
setUp()method callsparent::setUp(FALSE);so that the test views from ViewsTestBase are not added.$view = [];followed by separate assignments for each key.I have not attached an interdiff. The testing code is completely different, and there are only two lines (no change) outside the tests.
Comment #32
dawehnerI'm fine with whatever. I though believe that a functional test add more maintenance cost than a kernel test.
I think it would be better to start a new test class. This test is unrelated with the node revision wizard.
Comment #33
benjifisherKernel tests are harder to write, but I guess I need the experience. Maybe I should have said "integration test" instead of "functional test" in my previous comment.
Thanks to @tim.plunkett and @mglaman on Slack for helping me convert this to a Kernel test.
This time I am adding a test to
core/modules/node/tests/src/Kernel/Views/RevisionRelationshipsTest.php. The existing test in that class does not use Views UI, but I think the name of the class is general enough that the new test "fits".Again, I do not think that an interdiff would be helpful.
Comment #35
benjifisherHere is a slight simplification of the test, thanks to @dawehner's comment on #2947814: Use KernelTestBase::render() in CacheTest and IconBuilderTest. This time, an interdiff is appropriate.
I am living dangerously: I have not run the test locally.
Comment #37
ifrikThanks for adding a description to allow users to differentiate between the two relationships, but I also fail to understand the difference between the two options from the proposed wording.
I'm happy to help coming up with some wording once I understand what the difference is or what the different situation are in which a site builder would pick one or the other.
What is the difference between "this revision" and "current revision"?
And we need a more human readable text for "NULL otherwise".
Comment #38
ifrikComment #39
ifrikComment #41
benjifisher@ifrik: Thanks for offering to help with the wording!
Short version: by "current revision" I mean the value of
vidfrom thenodetable. By "this revision" I mean the value ofvidfrom thenode_revisiontable. The term "current revision" means the same thing it does on the Revisions page,/node/{nid}/revisions.Suppose the node with node ID
nid = 1has several revisions, with revision IDsvid = 1, 2, 3.Typically, the most recent revision ID is the current one. In this case, the
nodetable will have one row for this node, withnid = 1andvid = 3. Thenode_revisiontable will have three rows for this node:When we create a view of "Content revisions", we get all three rows from the
node_revisiontable. When we add a relation to thenodetable, we can either match on thenidcolumn or on thevidcolumn.Matching on
nidis what I label "Content associated to this revision". Using the word "Content" instead of "node" is my weak attempt at being user-friendly. When we choose this option, we get all the information from thenodetable added to each row of our view.Matching on
vidis what I label "Associated content for the current revision, NULL otherwise". When we choose this option, we get all the information from thenodetable added to the third row of the view. The other rows get a bunch of NULL values by default (using an outer join). If we check "Require this relationship" when adding the relation (meaning we tell Views to use an inner join) then those rows get removed.With content moderation, the value of
vidin thenodetable is the currently published revision, which may not be the most recent one.Comment #42
ifrikDiscussed at UX meeting on 18 Sept. One of the problems is that the audience of this text are site builders who might not have experience in doing this directly as database queries so wording like "join" or "NULL" would not help them. So we need a wording that aims at the site building experience.
Difficult points are what is the difference between "current revision" (the currently published version) and "this revision", and what the difference is in the results (rows) that the view will display.
We should also try to change the label and not just the description.
Comment #43
benjifisherWe talked about this at the weekly UX meeting today. A few suggestions came up:
I promised to generate some screenshots showing the results of each option, and we may bring it up again at the next UX meeting.
Comment #44
jrockowitz commentedThe attached patch always appends a handler's key to its option title. There are some fields that do append this information but it is not consistent.
Here is the before and after.
For me as a developer, having the (nid) or (vid) appended to the word 'Content' significant helps me understand what to expect when selecting a field, relationship, argument, etc…
The patch is just a proof-of-concept and I am not sure site builders need to see all this information.
Comment #45
benjifisher@jrockowitz: Style point
I prefer
" ($field_name)". The coding standards suggest this usage, but do not require it.Comment #46
jrockowitz commented@benjifisher I am open to working on the patch if this is the direction that we want to go in.
I think the field name could be smaller maybe a lighter gray and below the title.
Is showing the field name for all handlers worth pursuing?
If yes, this functionality should probably be implemented in a new ticket.
Comment #52
damienmckennaHow about working from @jrockowitz's suggested change in #44 to add the field name to the label for the benefit of people who know the difference between "nid" and "vid", and then make the description more verbose to clearly explain what it means for people who do not know what the technical terms mean? i.e. combining both suggestions and improving the wording further.
Comment #57
benjifisherI ran across this old issue while looking for something else.
I am closing this issue as outdated. In #2652652: Provide a relationship from the revision table to the main table, along with replacing the node-specific relationship with a more generic one, the labels were updated. Here is a screenshot:
The description does not explain exactly what the difference is, but it is clear that these are two different options. With a little experimentation, anyone building a view should be able to figure out which one to use.