[Profile][User_group] Fix profile deletion violating foreign keys

This commit is contained in:
Alexei Sorokin
2020-07-24 13:09:02 +03:00
parent 62f4dfdc7a
commit 33e9b57b78
2 changed files with 20 additions and 15 deletions

View File

@@ -978,6 +978,13 @@ class Profile extends Managed_DataObject
$this->_deleteAttentions();
Avatar::deleteFromProfile($this, true);
$this->grantRole(Profile_role::DELETED);
$localuser = User::getKV('id', $this->id);
if ($localuser instanceof User) {
$localuser->delete();
}
// Warning: delete() will run on the batch objects,
// not on individual objects.
$related = [
@@ -993,13 +1000,6 @@ class Profile extends Managed_DataObject
$inst->delete();
}
$this->grantRole(Profile_role::DELETED);
$localuser = User::getKV('id', $this->id);
if ($localuser instanceof User) {
$localuser->delete();
}
return parent::delete($useWhere);
}