]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/User.php
Allow blocking someone who's not currently subscribed to you (prevents seeing @-repli...
[quix0rs-gnu-social.git] / classes / User.php
index 8ad2ec63d5c81d12cbf6c3b35c7eb41b8cac5e60..1928a3c62fb1735b1c9ecab9a01595f6064ca191 100644 (file)
@@ -525,8 +525,8 @@ class User extends Memcached_DataObject
             common_log(LOG_WARNING,
                 sprintf(
                     "Profile ID %d (%s) tried to block his or herself.",
-                    $profile->id,
-                    $profile->nickname
+                    $this->id,
+                    $this->nickname
                 )
             );
             return false;
@@ -548,12 +548,9 @@ class User extends Memcached_DataObject
             return false;
         }
 
-        // Cancel their subscription, if it exists
-
-        $otherUser = User::staticGet('id', $other->id);
-
-        if (!empty($otherUser)) {
-            subs_unsubscribe_to($otherUser, $this->getProfile());
+        $self = $this->getProfile();
+        if (Subscription::exists($other, $self)) {
+            Subscription::cancel($other, $self);
         }
 
         $block->query('COMMIT');
@@ -670,8 +667,12 @@ class User extends Memcached_DataObject
 
     function delete()
     {
-        $profile = $this->getProfile();
-        $profile->delete();
+        try {
+            $profile = $this->getProfile();
+            $profile->delete();
+        } catch (UserNoProfileException $unp) {
+            common_log(LOG_INFO, "User {$this->nickname} has no profile; continuing deletion.");
+        }
 
         $related = array('Fave',
                          'Confirm_address',
@@ -679,6 +680,7 @@ class User extends Memcached_DataObject
                          'Foreign_link',
                          'Invitation',
                          );
+
         Event::handle('UserDeleteRelated', array($this, &$related));
 
         foreach ($related as $cls) {