]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Ticket #2441: fix deletion of avatars when a profile is deleted.
authorBrion Vibber <brion@status.net>
Fri, 19 Nov 2010 20:39:07 +0000 (12:39 -0800)
committerBrion Vibber <brion@status.net>
Fri, 19 Nov 2010 20:40:18 +0000 (12:40 -0800)
Code was doing a batch call to $avatar->delete() which fails to properly engage the file deletion code. Calling the existing profile->delete_avatars() function deletes them individually, which makes it all work nice again.

classes/Profile.php

index b11cffc776cc496d24d5396f454d2e40aea416f5..2e88f17ad3d787b665750359a7d5726464a5e4b2 100644 (file)
@@ -125,6 +125,14 @@ class Profile extends Memcached_DataObject
         return $avatar;
     }
 
+    /**
+     * Delete attached avatars for this user from the database and filesystem.
+     * This should be used instead of a batch delete() to ensure that files
+     * get removed correctly.
+     *
+     * @param boolean $original true to delete only the original-size file
+     * @return <type>
+     */
     function delete_avatars($original=true)
     {
         $avatar = new Avatar();
@@ -643,9 +651,11 @@ class Profile extends Memcached_DataObject
         $this->_deleteMessages();
         $this->_deleteTags();
         $this->_deleteBlocks();
+        $this->delete_avatars();
 
-        $related = array('Avatar',
-                         'Reply',
+        // Warning: delete() will run on the batch objects,
+        // not on individual objects.
+        $related = array('Reply',
                          'Group_member',
                          );
         Event::handle('ProfileDeleteRelated', array($this, &$related));