Hello everyone,

First let me explain steps to reproduce:

- Created some node with User A
- Added a revision with User B
- Deleted User A migrating all its content to anonymous
- Revisions of User B disappeared or were assigned to anonymous too.

My thoughts on why:

First of all we have two major tables saving revisions data, the node_field_revision and the node_revision. For some reason I don't know why the node_field_revision saves for every revision added the uid, and this value will always be the author of the content (In this case user A), in other hand the node_revision table saves the revision_uid and this is the correct value (the user who created the new revision).

When I delete a user "node_user_cancel" function is triggered and this line "$vids = \Drupal::entityManager()->getStorage('node')->userRevisionIds($account);" will retrieve the revisions from node_field_revision table, here I think we've the first problem because we're assigning the anonymous to uid and revision_uid on both tables (here the revision of user B is also assigned to anonymous), and for some reason the batch runned successfully and finished, however some revisions remained on node_field_revision with the old uid (second problem, no issues occured during batch neither logs). the third problem and more serious one, in the function "node_user_predelete", after the batch runs is looking again to table node_field_revision and because all revisions in this table are assigned to user A (and for some reason were keep with his uid (not anonymous)) are deleted, without any check on the option I selected which was "user_cancel_reassign", not "user_cancel_delete". This is a very dangerous behaviour and I think it should be re-designed or re-thinked.

Any thoughts on this, anything I'm missing?

Comments

joao133 created an issue. See original summary.

joaogomes_cd’s picture

Issue summary: View changes
joaogomes_cd’s picture

Priority: Normal » Major
cilefen’s picture

For a bug, the issue title could be more descriptive, which is perhaps why no one has commented.

joaogomes_cd’s picture

Title: User Delete vs Content Revision » User Delete removes revisions

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

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

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