🇬🇧United Kingdom @samuelpodina

Account created on 4 April 2018, over 6 years ago
#

Recent comments

🇬🇧United Kingdom samuelpodina

here's the same patch against latest 2.x dev

🇬🇧United Kingdom samuelpodina

here's the same patch against latest 2.x dev (which also applies to 2 for D10)

🇬🇧United Kingdom samuelpodina

I modified the patch so it works in D10.

🇬🇧United Kingdom samuelpodina

I've update the patch @lukas-von-blarer made so it applies on the new version of the module.

🇬🇧United Kingdom samuelpodina

@grevil thank you for taking the time to review, test and refactor

🇬🇧United Kingdom samuelpodina

@grevil this happened when you chose the option to delete the user and it's content?

🇬🇧United Kingdom samuelpodina

Switched to dependency injection usage for entity type manager and db connection.

🇬🇧United Kingdom samuelpodina

@anybody because all of this happens before the predelete hook is called which means all nodes that haven't been processed/reassigned go through node_user_predelete which runs the following code:

/**
 * Implements hook_ENTITY_TYPE_predelete() for user entities.
 */
function node_user_predelete($account) {
  // Delete nodes (current revisions).
  // @todo Introduce node_mass_delete() or make node_mass_update() more flexible.
  $nids = \Drupal::entityQuery('node')
    ->condition('uid', $account->id())
    ->accessCheck(FALSE)
    ->execute();
  // Delete old revisions.
  $storage_controller = \Drupal::entityTypeManager()->getStorage('node');
  $nodes = $storage_controller->loadMultiple($nids);
  $storage_controller->delete($nodes);
  $revisions = $storage_controller->userRevisionIds($account);
  foreach ($revisions as $revision) {
    node_revision_delete($revision);
  }
}

I think I found a better way to cover all types of entities not just node. I created an new patch let me know what you think.

🇬🇧United Kingdom samuelpodina

@anybody I don't think the system setting has any impact on this since this modules invokes the user_cancel with the correct method selected in the purge_users module config.

🇬🇧United Kingdom samuelpodina

After more investigations I think content gets delete when a users own more then 10 content items. For example node entity switches to the Batch api if there more then 10 nodes checkout /core/modules/node/node.module line 651 is calling the node_mass_update method. I believe the batch api need browser access to work that's why when you delete a user with less then 10 items it works. I think we need to come up with a different approach to reassign content, maybe a hook_user_predelete.

🇬🇧United Kingdom samuelpodina

This seems to be still an issue we recently patch this for one of our website and it seems to be working pretty well. I thought I'd share it here. Let me know your thoughts. The logic is quite straight forward and is running to updated queries to reassign the user ID before the user gets deleted.

Production build 0.71.5 2024