summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@status.net>2010-11-19 12:39:07 -0800
committerBrion Vibber <brion@status.net>2010-11-19 12:40:18 -0800
commit4b01dd8b2ec18c28a49fd8963dd7e31e73b4670b (patch)
tree93b13edfcdf70edf1f18d080b2c698caff5d9c38
parentd96192587451bfaaaa4889b7c69db0a2fbe14c41 (diff)
Ticket #2441: fix deletion of avatars when a profile is deleted.
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.
-rw-r--r--classes/Profile.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/classes/Profile.php b/classes/Profile.php
index b11cffc77..2e88f17ad 100644
--- a/classes/Profile.php
+++ b/classes/Profile.php
@@ -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));