]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge commit 'origin/0.9.x' into 0.9.x
[quix0rs-gnu-social.git] / classes / Notice.php
index 3126cc064764c9b8adc65216aea6010ea681018e..bcd7947bd17fa848f5f5535f50e74d22f6e9d27e 100644 (file)
@@ -922,13 +922,14 @@ class Notice extends Memcached_DataObject
         }
 
         $groups = $this->saveGroups();
+        $profile = $this->getProfile();
 
         foreach ($groups as $group) {
             $users = $group->getUserMembers();
             foreach ($users as $id) {
                 if (!array_key_exists($id, $ni)) {
                     $user = User::staticGet('id', $id);
-                    if (!$user->hasBlocked($notice->profile_id)) {
+                    if (!$user->hasBlocked($profile)) {
                         $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
                     }
                 }
@@ -947,39 +948,7 @@ class Notice extends Memcached_DataObject
             }
         }
 
-        $cnt = 0;
-
-        $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
-        $qry = $qryhdr;
-
-        foreach ($ni as $id => $source) {
-            if ($cnt > 0) {
-                $qry .= ', ';
-            }
-            $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
-            $cnt++;
-            if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
-                // FIXME: Causes lag in replicated servers
-                // Notice_inbox::gc($id);
-            }
-            if ($cnt >= MAX_BOXCARS) {
-                $inbox = new Notice_inbox();
-                $result = $inbox->query($qry);
-                if (PEAR::isError($result)) {
-                    common_log_db_error($inbox, $qry);
-                }
-                $qry = $qryhdr;
-                $cnt = 0;
-            }
-        }
-
-        if ($cnt > 0) {
-            $inbox = new Notice_inbox();
-            $result = $inbox->query($qry);
-            if (PEAR::isError($result)) {
-                common_log_db_error($inbox, $qry);
-            }
-        }
+        Notice_inbox::bulkInsert($this->id, $this->created, $ni);
 
         return;
     }