forked from GNUsocial/gnu-social
better deletion of related objects in User_group::delete()
This commit is contained in:
parent
ddb60a8191
commit
76038fe20c
@ -559,16 +559,27 @@ class User_group extends Memcached_DataObject
|
|||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
if ($this->id) {
|
if ($this->id) {
|
||||||
|
|
||||||
// Safe to delete in bulk for now
|
// Safe to delete in bulk for now
|
||||||
|
|
||||||
$related = array('Group_inbox',
|
$related = array('Group_inbox',
|
||||||
'Group_block',
|
'Group_block',
|
||||||
'Group_member',
|
'Group_member',
|
||||||
'Related_group');
|
'Related_group');
|
||||||
|
|
||||||
Event::handle('UserGroupDeleteRelated', array($this, &$related));
|
Event::handle('UserGroupDeleteRelated', array($this, &$related));
|
||||||
|
|
||||||
foreach ($related as $cls) {
|
foreach ($related as $cls) {
|
||||||
|
|
||||||
$inst = new $cls();
|
$inst = new $cls();
|
||||||
$inst->group_id = $this->id;
|
$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...
|
// And related groups in the other direction...
|
||||||
@ -584,6 +595,10 @@ class User_group extends Memcached_DataObject
|
|||||||
if ($local) {
|
if ($local) {
|
||||||
$local->delete();
|
$local->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// blow the cached ids
|
||||||
|
self::blow('user_group:notice_ids:%d', $this->id);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
common_log(LOG_WARN, "Ambiguous user_group->delete(); skipping related tables.");
|
common_log(LOG_WARN, "Ambiguous user_group->delete(); skipping related tables.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user