From: Mikael Nordfeldth Date: Thu, 6 Mar 2014 13:43:36 +0000 (+0100) Subject: Clear Attentions when notice or profile is removed X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5e4a2752202cb4a06367b059f5d3ad8bc03eb2ef;p=quix0rs-gnu-social.git Clear Attentions when notice or profile is removed --- diff --git a/classes/Notice.php b/classes/Notice.php index 3fea531081..fe1442ea97 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -194,8 +194,8 @@ class Notice extends Managed_DataObject $this->clearTags(); $this->clearGroupInboxes(); $this->clearFiles(); + $this->clearAttentions(); - // NOTE: we don't clear inboxes // NOTE: we don't clear queue items } @@ -1910,6 +1910,20 @@ class Notice extends Managed_DataObject return $options; } + function clearAttentions() + { + $att = new Attention(); + $att->notice_id = $this->getID(); + + if ($att->find()) { + while ($att->fetch()) { + // Can't do delete() on the object directly since it won't remove all of it + $other = clone($att); + $other->delete(); + } + } + } + function clearReplies() { $replyNotice = new Notice(); diff --git a/classes/Profile.php b/classes/Profile.php index fe2ce343d7..6adf059781 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -924,6 +924,7 @@ class Profile extends Managed_DataObject $this->_deleteMessages(); $this->_deleteTags(); $this->_deleteBlocks(); + $this->_deleteAttentions(); Avatar::deleteFromProfile($this, true); // Warning: delete() will run on the batch objects, @@ -1025,6 +1026,20 @@ class Profile extends Managed_DataObject $block->delete(); } + function _deleteAttentions() + { + $att = new Attention(); + $att->profile_id = $this->getID(); + + if ($att->find()) { + while ($att->fetch()) { + // Can't do delete() on the object directly since it won't remove all of it + $other = clone($att); + $other->delete(); + } + } + } + // XXX: identical to Notice::getLocation. public function getLocation()