]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Infinite loop on CLI initiated profile deletion for local users
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 18 Jul 2015 00:16:52 +0000 (02:16 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 18 Jul 2015 00:16:52 +0000 (02:16 +0200)
profile deleting user deleting profile deleting user...

classes/Profile.php
classes/User.php
lib/deluserqueuehandler.php

index 5359ffb58b31444a19b3a265278489c9e0fa5f73..09f9ca71d109933db6509cb883ec1bee866d222c 100644 (file)
@@ -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();
index 5b9d7b51fec351924d196f882465ca785fed683c..e33c83e89cf0f74f3c07957a4caec50e94f84624 100644 (file)
@@ -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.");
         }
index 1baaf9331f2bf7e9752ec8565ca6ab08c1efd511..65866af4184d20fe43e48fdfeeba64156a5ee46b 100644 (file)
@@ -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;
         }