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:

"Add relationships" dialogue

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.

screenshot after patch from #2

API changes

None

Data model changes

None

Comments

benjifisher created an issue. See original summary.

benjifisher’s picture

Here is one suggestion for the wording:

Add relationships dialogue with added descriptions

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.module component. 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.

Status: Needs review » Needs work

The last submitted patch, 2: 2932880-views-revision-relationship-2.patch, failed testing. View results

benjifisher’s picture

Status: Needs work » Needs review
marcoscano’s picture

Status: Needs review » Reviewed & tested by the community

Manually 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...

benjifisher’s picture

Issue summary: View changes

Thanks 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 vid and make it an inner join by checking "Require this relationship".

benjifisher’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

@xjm points out that this needs tests. I am also going to look (again) for a duplicate issue.

benjifisher’s picture

Issue summary: View changes
Issue tags: +Needs usability review
benjifisher’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs usability review
StatusFileSize
new3.95 KB

I 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.

Status: Needs review » Needs work

The last submitted patch, 9: 2932880-views-revision-relationship-9.patch, failed testing. View results

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new3.94 KB

As I said, I need practice writing these tests.

Status: Needs review » Needs work

The last submitted patch, 11: 2932880-views-revision-relationship-11.patch, failed testing. View results

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new3.61 KB

Try again.

Status: Needs review » Needs work

The last submitted patch, 13: 2932880-views-revision-relationship-13.patch, failed testing. View results

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new3.61 KB

Making progress.

Status: Needs review » Needs work

The last submitted patch, 15: 2932880-views-revision-relationship-15.patch, failed testing. View results

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new3.63 KB

and again

Status: Needs review » Needs work

The last submitted patch, 17: 2932880-views-revision-relationship-17.patch, failed testing. View results

benjifisher’s picture

Status: Needs work » Needs review
StatusFileSize
new3.58 KB

Try a different selector to open the "Advanced" section of the Views edit page.

Status: Needs review » Needs work

The last submitted patch, 19: 2932880-views-revision-relationship-19.patch, failed testing. View results

benjifisher’s picture

I 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:

    $this->drupalGet('admin/structure/views/add');
    $name = $this->randomMachineName();
    $machine_name = strtolower($name);
    $page->fillField('label', $name);
    $page->fillField('id', $machine_name);

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

marcoscano’s picture

+++ b/core/modules/node/tests/src/FunctionalJavascript/TestViewsInterfaceText.php
@@ -0,0 +1,71 @@
+    // Open the Advanced settings.
+    $locator = '.views-display-column.third';
+    $result = $assert_session->waitForElement('css', $locator);
...
+    // Open the "Add relationships" modal window.
+    $result = $assert_session->waitForLink('views-add-relationship');

I'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!

benjifisher’s picture

Exactly: 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.

mpdonadio’s picture

Assigned: Unassigned » mpdonadio

Reviewing this as part of mentoring.

schiavone’s picture

Reviewed 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.

schiavone’s picture

Status: Needs review » Reviewed & tested by the community
dawehner’s picture

Is 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.

benjifisher’s picture

Assigned: mpdonadio » Unassigned
Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.37 KB
new3.46 KB

@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:

  1. Add three lines to the existing test method, even though they are not related to the name of the class nor method.
  2. Add another test method in the class (and refactor the existing test into a setUp() and a test).
  3. Add an entirely new test class.

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:

  • The setUp() method calls parent::setUp(FALSE); so that the test views from ViewsTestBase are not added.
  • I rewrote the array definition as a single, multi-line assignment instead of $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.

dawehner’s picture

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).

I'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.

benjifisher’s picture

Kernel 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.

benjifisher’s picture

Here 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.

ifrik’s picture

Thanks 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".

ifrik’s picture

Status: Needs review » Active
ifrik’s picture

Status: Active » Needs work

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

benjifisher’s picture

@ifrik: Thanks for offering to help with the wording!

Short version: by "current revision" I mean the value of vid from the node table. By "this revision" I mean the value of vid from the node_revision table. The term "current revision" means the same thing it does on the Revisions page, /node/{nid}/revisions.

Suppose the node with node ID nid = 1 has several revisions, with revision IDs vid = 1, 2, 3.

Typically, the most recent revision ID is the current one. In this case, the node table will have one row for this node, with nid = 1 and vid = 3. The node_revision table will have three rows for this node:

nid | vid
  1 | 1
  1 | 2
  1 | 3

When we create a view of "Content revisions", we get all three rows from the node_revision table. When we add a relation to the node table, we can either match on the nid column or on the vid column.

Matching on nid is 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 the node table added to each row of our view.

Matching on vid is what I label "Associated content for the current revision, NULL otherwise". When we choose this option, we get all the information from the node table 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 vid in the node table is the currently published revision, which may not be the most recent one.

ifrik’s picture

Issue tags: +user interface text

Discussed 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.

benjifisher’s picture

We talked about this at the weekly UX meeting today. A few suggestions came up:

  1. Change the Title column as well as the Description column.
  2. Perhaps change the Title column to "Content (nid)" and "Content (vid)", similar to the "Image (field_image:target_id)" line in the screenshots.
  3. Use "results" rather than "rows" to describe what-it-is-that-views-produces.
  4. Use "empty" rather than "NULL".
  5. Give a longer description of at least one of the options. Something like, "Add this relationship and make it required to get just one result for each node." Of course, we try to avoid "node" in the admin UI, so not exactly that.

I promised to generate some screenshots showing the results of each option, and we may bring it up again at the next UX meeting.

jrockowitz’s picture

The 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.

Views Relationships before patch is applied

Views Relationships after patch is applied

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.

benjifisher’s picture

@jrockowitz: Style point

+          $option['title'] .= ' ('. $field_name .')';

I prefer " ($field_name)". The coding standards suggest this usage, but do not require it.

jrockowitz’s picture

@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.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

damienmckenna’s picture

How 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.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

benjifisher’s picture

Status: Needs work » Closed (outdated)
Related issues: +#2652652: Provide a relationship from the revision table to the main table
StatusFileSize
new58.28 KB

I 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:

Screenshot showing the labels 'Content' and 'Content revision'

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.