Comments

vvvi’s picture

subscribe

siegoboy’s picture

Hi

I have the same problem and I am not sure what do you mean by subscribe?

Is there a solution to this?

Thank You,

Siegfried

joachim’s picture

Looks like we're missing an implementation of hook_user_delete().

The fix for this would be pretty simple, if anyone wants to work on a patch. Just move the body of profile2_user_cancel() to a new function, and have both profile2_user_cancel() and hook_user_delete() call that.

siegoboy’s picture

Thanks for the reply!

Wow that sounds simple enough.

My Druple knowledge is very limited, but it would be great if someone could implement this hook.

joachim’s picture

> My Druple knowledge is very limited

It would be a great opportunity to get stuck in and learn more :D
Start at http://drupal.org/patch for instructions on how to make a patch...

siegoboy’s picture

Cool!

I will do!

Thanks!

Countzero’s picture

StatusFileSize
new1011 bytes

Here is a simple-quickly-tested patch following Joachim's advice. Should apply to beta2.

joachim’s picture

Status: Active » Needs work

Thanks for the patch. Looks good!

Just a few things to tidy up and we're there :)

+++ b/profile2.module
@@ -242,10 +242,13 @@ function profile2_delete_multiple(array $pids) {
+    user_delete_profile($account);

Be careful with your indentation -- just two spaces.

+++ b/profile2.module
@@ -272,6 +275,15 @@ function profile2_type_save(ProfileType $type) {
+/** ¶

There's a stray space at the end of this line.

+++ b/profile2.module
@@ -272,6 +275,15 @@ function profile2_type_save(ProfileType $type) {
+function user_delete_profile($account) {

It's good practice to namespace all functions. So this should be called profile2_delete_all_by_user, probably.

Powered by Dreditor.

Countzero’s picture

StatusFileSize
new1.01 KB

Should be good now.

Countzero’s picture

StatusFileSize
new1.01 KB

Carrier return still there in previous version. Should have been deleted.

joachim’s picture

Nearly there! :)

+++ b/profile2.module
@@ -272,6 +275,15 @@ function profile2_type_save(ProfileType $type) {
+/**
+* Deletes profile information for a canceled or deleted user
+*/

Need a full stop at the end of the comment, and the two lines that start with a * need one space in, so the comment block is like this:

/**
 *
 */

Powered by Dreditor.

Countzero’s picture

StatusFileSize
new1.01 KB

My ...

Countzero’s picture

StatusFileSize
new1.04 KB

Carrier return back in last version. Sorry.

Jerome F’s picture

I marked my own issue as duplicate when I found this one.
(I've provided as much details as I could there: http://drupal.org/node/1135744)

Countzero’s picture

Shouldn't this issue be in status 'needs review' ?

Jerome F’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #14 solves the problem. When a user is deleted, the profile table is updated accordingly.
Thank you Countzero and joachim

(@siegoboy: Drupal community is raising funds to kill the subscribe comments : http://drupal.org/node/34496 - http://3281d.com/2009/03/27/death-to-subscribe-comments)

joachim’s picture

Status: Needs work » Reviewed & tested by the community

Will commit with minor tweaks when I get the chance:

> + // Delete all profiles of the user in any case.

That can go.

> + * Deletes profile information for a canceled or deleted user

Needs a full stop.

joachim’s picture

Status: Reviewed & tested by the community » Fixed
StatusFileSize
new958 bytes

Also moved the new function to a more logical place in the code.

Committed this patch.

dave reid’s picture

Status: Fixed » Needs work

BTW, there's no need to implement both hook_user_delete() and hook_user_cancel(). Only hook_user_delete() should be necessary as that's the one that's executed when data is removed. A user could cancel their own account to have it un-blocked later, so their profile shouldn't probably be deleted in that case.

joachim’s picture

Oh, so what we should have done with this patch was *change* hook_user_cancel to hook_user_delete... :/

jide’s picture

Status: Needs work » Needs review
StatusFileSize
new467 bytes

I think the best thing to do here would be to delete user profile when :

  • A user account is deleted
  • A user account is canceled AND reassigned to anonymous

In both cases data is lost.

Patch attached.

ericbroder’s picture

#1065860-2: Profile data not deleted when user account is deleted

Siegfried, the purpose of saying "subscribe" is usually to just simply comment on the current issue so that you can more easily follow issue updates.

ericbroder’s picture

StatusFileSize
new475 bytes

This is just a cleaner version of the patch in #1065860-21: Profile data not deleted when user account is deleted.

Summary of expected result based on cancellation option:
- Disable the account and keep its content: leave profile data alone.
- Disable the account and unpublish its content: leave profile data alone.
- Delete the account and make its content belong to the Anonymous user: remove profile data using hook_user_cancel.
- Delete the account and its content: remove profile data using hook_user_delete.

It appears that hook_user_delete is not actually called for the option "Delete the account and make its content belong to the Anonymous user", that actually calls hook_user_cancel with method user_cancel_reassign.

UPDATE: This seems to be incorrect: ...hook_user_delete is not actually called for the option "Delete the account and make its content belong to the Anonymous user". See #1065860-25: Profile data not deleted when user account is deleted.

joachim’s picture

> It appears that hook_user_delete is not actually called for the option "Delete the account and make its content belong to the Anonymous user", that actually calls hook_user_cancel with method user_cancel_reassign.

Looks like the docs for a few of the functions in user module could do with patches...

dave reid’s picture

Status: Reviewed & tested by the community » Needs review

Check out http://api.drupal.org/api/drupal/modules--user--user.module/function/_us...

    case 'user_cancel_reassign':
    case 'user_cancel_delete':
      // Send account canceled notification if option was checked.
      if (!empty($edit['user_cancel_notify'])) {
        _user_mail_notify('status_canceled', $account);
      }
      user_delete($account->uid);
      drupal_set_message(t('%name has been deleted.', array('%name' => $account->name)));
      watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE);
      break;

user_delete() calls hook_user_delete(), so yes it is called for the user_cancel_reassign action. :)

ericbroder’s picture

StatusFileSize
new891 bytes

Thanks Dave Reid, I think you're right, I cannot reproduce my own results that I stated above.

Here's a new patch based on #1065860-20: Profile data not deleted when user account is deleted.

fago’s picture

Status: Needs review » Fixed

yep, just using hook_user_delete() should be fine. Committed, thanks.

Status: Fixed » Closed (fixed)

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