return true;
}
- $user = User::staticGet('id', $user->id);
+ $user = User::getKV('id', $user->id);
if (!$user) {
common_log(LOG_INFO, "User {$user->nickname} was deleted before we got here.");
return true;
}
- if (!$user->hasRole(Profile_role::DELETED)) {
- common_log(LOG_INFO, "User {$user->nickname} is not pending deletion; aborting.");
- return true;
+ try {
+ if (!$user->hasRole(Profile_role::DELETED)) {
+ common_log(LOG_INFO, "User {$user->nickname} is not pending deletion; aborting.");
+ return true;
+ }
+ } catch (UserNoProfileException $unp) {
+ common_log(LOG_INFO, "Deleting user {$user->nickname} with no profile... probably a good idea!");
}
$notice = $this->getNextBatch($user);
$qm = QueueManager::get();
$qm->enqueue($user, 'deluser');
} else {
- // Out of notices? Let's finish deleting this guy!
- $user->delete();
+ // Out of notices? Let's finish deleting this profile!
+ try {
+ $user->getProfile()->delete();
+ } catch (UserNoProfileException $e) {
+ // in case a profile didn't exist for some reason, just delete the User directly
+ $user->delete();
+ }
common_log(LOG_INFO, "User $user->id $user->nickname deleted.");
return true;
}