Problem

When a user account is deleted (with "Delete user account and assign content to anonymous user" or "Delete user account and delete content") posts can become orphaned. This causes the posts overview to break and has some other side effects.

How to reproduce

- Create an Open Social distro install with demo content.
- Delete the Chris Hall user with one of the two mentioned options
- Note that the user profile for Chris Hall has gone missing although he still has a post in the stream (that should've been an anonymous post, or the post should'e been deleted). You now also receive an error when trying to go to the posts overview page at /admin/content/post.

Cause

The social_post module does not implement the hook_user_cancel and hook_user_predelete hooks that are designed to perform these operations. An example implementation can be found in Drupal core's node.module

Proposed resolution

Copy the node module's implementation for each option to the social_post module and adjust it to work for the Post entity.

Follow-up

Are there any other entities that we have created ourselves that could suffer from this? Issues should be filed for those as well.

Comments

Kingdutch created an issue. See original summary.

kingdutch’s picture

Assigned: kingdutch » Unassigned
Status: Active » Needs work

Work on this has been done on https://github.com/goalgorilla/open_social/commits/bugfix/2930486-post-u...

It appears the issue itself is fixed but the test that's been added can't succeed because the activity doesn't change the name of the person who posted the post as a result of the change of owner of the post.

I'm unsure how to change that activity or what would be a good way to modify this test.

kingdutch’s picture

Status: Needs work » Needs review

A pull request has been created here: https://github.com/goalgorilla/open_social/pull/694

The code in the Pull Request is already used by one of our enterprise projects (as a downloaded patch).

ronaldtebrake’s picture

Status: Needs review » Fixed

Thanks, will be in 3.0!

Status: Fixed » Closed (fixed)

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