Problem/Motivation

Relationships for users to the nodes they've created are defined by the User module. The Node module may be uninstalled, but the User module may not. So the User module provides view relationships that can be invalid.

Steps to reproduce

  1. Uninstall the Node module.
  2. Add a new view for User entities.
  3. Begin to add a relationship to the view. Note that you can add relationships for "Content Authored" and "Representative Node" despite the fact that the Node module is uninstalled.
  4. Add the relationship for "Content Authored" and observe the following error in the view's preview:
    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd8_dev.node_field_data' doesn't exist: SELECT users_field_data.created AS users_field_data_created, users_field_data.uid AS uid FROM {users_field_data} users_field_data LEFT JOIN {node_field_data} node_field_data_users_field_data ON users_field_data.uid = node_field_data_users_field_data.uid WHERE (( (users_field_data.status = :db_condition_placeholder_0) )) ORDER BY users_field_data_created DESC LIMIT 11 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 )
  5. Remove the relationship added in the last step and add a "Representative Node" relationship to the view. Observe the view admin page blow up with even more errors.

Proposed resolution

Move the "Content Authored" and "Representative Node" view relationship definitions to the node module in a hook_views_data_alter() implementation.

Remaining tasks

Write the code.

User interface changes

The content authored relationship will not be visible in user-based views if the node module is not enabled. The following screenshots of User relationships were taken with the Node module uninstalled.

Before:
A screenshot of the possible views relationships for users

After:
A screenshot of the possible views relationships for users after applying the MR which does not contain the invalid relationships

API changes

Data model changes

CommentFileSizeAuthor
#19 after.png21.25 KBdcam
#19 before.png30.64 KBdcam

Issue fork drupal-2781815

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Jelle_S created an issue. See original summary.

jelle_s’s picture

Issue summary: View changes

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.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.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
catch’s picture

Issue tags: +Bug Smash Initiative

This is still valid - node module is optional, user module isn't.

There should be a ticket somewhere to make this generic for entities that implement EntityOwnerInterface, in which case it could move back to user module, but then it would still need to correctly handle modules being enabled or disabled.

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

danielveza made their first commit to this issue’s fork.

danielveza’s picture

Status: Active » Needs review

Given this a first crack, tests are green.

dcam’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new30.64 KB
new21.25 KB

I didn't find anything to comment about on the MR. The code changes look good to me.

I proceeded to verify the bug. It was pretty easy to replicate, but I rewrote the steps to reproduce the issue based on the experience.

After applying the MR the two invalid relationships are no longer available in the views admin UI when the Node module is uninstalled.

In my opinion this bug qualifies as one that doesn't need regression tests. It checks all of the boxes in the list of reasons why a test might not be needed.

I tested what happens to existing affected views on a site:

  • If the view exists when Node is uninstalled, then the view is deleted. This makes sense. The config dependency system works.
  • More importantly, on a site with Node uninstalled a view may created with one of these invalid relationships. If a person has done this and somehow not paid attention to all the errors that popped up and then this change is applied to the site, then the relationship shows "Broken/missing handler" in the admin UI. That's also what I expected.

I don't know that we need an update function to correct these broken views. I feel like the broken/missing handler warning is preferable to modifying a view. But I don't know what the usual procedure is in this situation. I'm going to proceed with setting this issue to RTBC, but a committer should weigh in on this subject.

dcam’s picture

Priority: Major » Normal

Based on what I've seen this doesn't qualify for Major status.

  • longwave committed 57f0056f on 11.x
    fix: #2781815 Content authored views relationship should be provided by...

  • longwave committed df31ad4e on main
    fix: #2781815 Content authored views relationship should be provided by...
longwave’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed df31ad4e31b to main and 57f0056f0cc to 11.x. Thanks!

Decided not to backport further as this is a niche problem where if users already had this problem in a site they would have worked around it by now, but new sites will not run into it.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.