]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge remote branch 'chat-interface-plugins/irc-plugin' into 1.0.x
[quix0rs-gnu-social.git] / classes / Notice.php
index 4646fc6aba2778fbb6511a826ca12fc87cf7f0d3..5a70f70b6461c16b888301fc53d1213590e57d57 100644 (file)
@@ -121,16 +121,19 @@ class Notice extends Memcached_DataObject
             $deleted->insert();
         }
 
-        // Clear related records
+        if (Event::handle('NoticeDeleteRelated', array($this))) {
 
-        $this->clearReplies();
-        $this->clearRepeats();
-        $this->clearFaves();
-        $this->clearTags();
-        $this->clearGroupInboxes();
+            // Clear related records
 
-        // NOTE: we don't clear inboxes
-        // NOTE: we don't clear queue items
+            $this->clearReplies();
+            $this->clearRepeats();
+            $this->clearFaves();
+            $this->clearTags();
+            $this->clearGroupInboxes();
+
+            // NOTE: we don't clear inboxes
+            // NOTE: we don't clear queue items
+        }
 
         $result = parent::delete();
 
@@ -245,6 +248,8 @@ class Notice extends Memcached_DataObject
         if (!empty($options)) {
             $options = $options + $defaults;
             extract($options);
+        } else {
+            extract($defaults);
         }
 
         if (!isset($is_local)) {
@@ -485,7 +490,7 @@ class Notice extends Memcached_DataObject
     function saveKnownUrls($urls)
     {
         // @fixme validation?
-        foreach ($urls as $url) {
+        foreach (array_unique($urls) as $url) {
             File::processNew($url, $this->id);
         }
     }
@@ -893,7 +898,7 @@ class Notice extends Memcached_DataObject
         }
 
         $groups = array();
-        foreach ($group_ids as $id) {
+        foreach (array_unique($group_ids) as $id) {
             $group = User_group::staticGet('id', $id);
             if ($group) {
                 common_log(LOG_ERR, "Local delivery to group id $id, $group->nickname");
@@ -1016,7 +1021,7 @@ class Notice extends Memcached_DataObject
         }
         $sender = Profile::staticGet($this->profile_id);
 
-        foreach ($uris as $uri) {
+        foreach (array_unique($uris) as $uri) {
 
             $user = User::staticGet('uri', $uri);
 
@@ -1029,6 +1034,7 @@ class Notice extends Memcached_DataObject
 
                 $reply->notice_id  = $this->id;
                 $reply->profile_id = $user->id;
+                common_log(LOG_INFO, __METHOD__ . ": saving reply: notice $this->id to profile $user->id");
 
                 $id = $reply->insert();
             }