From 6f62adedfc44306e1df2a63e030f8b29e334f3a2 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 18 Jul 2015 02:16:52 +0200 Subject: [PATCH] Infinite loop on CLI initiated profile deletion for local users profile deleting user deleting profile deleting user... --- classes/Profile.php | 5 +++++ classes/User.php | 6 ++++-- lib/deluserqueuehandler.php | 9 +++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index 5359ffb58b..09f9ca71d1 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -877,6 +877,11 @@ class Profile extends Managed_DataObject function delete($useWhere=false) { + // just in case it hadn't been done before... (usually set before adding deluser to queue handling!) + if (!$this->hasRole(Profile_role::DELETED)) { + $this->grantRole(Profile_role::DELETED); + } + $this->_deleteNotices(); $this->_deleteSubscriptions(); $this->_deleteTags(); diff --git a/classes/User.php b/classes/User.php index 5b9d7b51fe..e33c83e89c 100644 --- a/classes/User.php +++ b/classes/User.php @@ -598,8 +598,10 @@ class User extends Managed_DataObject } try { - $profile = $this->getProfile(); - $profile->delete(); + if (!$this->hasRole(Profile_role::DELETED)) { + $profile = $this->getProfile(); + $profile->delete(); + } } catch (UserNoProfileException $unp) { common_log(LOG_INFO, "User {$this->nickname} has no profile; continuing deletion."); } diff --git a/lib/deluserqueuehandler.php b/lib/deluserqueuehandler.php index 1baaf9331f..65866af418 100644 --- a/lib/deluserqueuehandler.php +++ b/lib/deluserqueuehandler.php @@ -74,8 +74,13 @@ class DelUserQueueHandler extends QueueHandler $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; } -- 2.39.5