diff options
author | Evan Prodromou <evan@status.net> | 2010-10-13 22:44:06 -0400 |
---|---|---|
committer | Evan Prodromou <evan@status.net> | 2010-10-13 22:44:06 -0400 |
commit | 76038fe20c7ebd732ffbc659827ab812ee5a4b6e (patch) | |
tree | 7b838c9dd69b7351e98eeb2bb7abadaf5b1e0bfb /classes/User_group.php | |
parent | ddb60a8191de23fc11f6711954575ac7b6f49998 (diff) |
better deletion of related objects in User_group::delete()
Diffstat (limited to 'classes/User_group.php')
-rw-r--r-- | classes/User_group.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/classes/User_group.php b/classes/User_group.php index 1f7005785..7d6e21914 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -559,16 +559,27 @@ class User_group extends Memcached_DataObject function delete() { if ($this->id) { + // Safe to delete in bulk for now + $related = array('Group_inbox', 'Group_block', 'Group_member', 'Related_group'); + Event::handle('UserGroupDeleteRelated', array($this, &$related)); + foreach ($related as $cls) { + $inst = new $cls(); $inst->group_id = $this->id; - $inst->delete(); + + if ($inst->find()) { + while ($inst->fetch()) { + $dup = clone($inst); + $dup->delete(); + } + } } // And related groups in the other direction... @@ -584,6 +595,10 @@ class User_group extends Memcached_DataObject if ($local) { $local->delete(); } + + // blow the cached ids + self::blow('user_group:notice_ids:%d', $this->id); + } else { common_log(LOG_WARN, "Ambiguous user_group->delete(); skipping related tables."); } |