]> git.mxchange.org Git - friendica.git/commitdiff
Avoid SQL errors due to duplicate entries in the "participation" table
authorMichael <heluecht@pirati.ca>
Thu, 8 Mar 2018 21:04:11 +0000 (21:04 +0000)
committerMichael <heluecht@pirati.ca>
Thu, 8 Mar 2018 21:04:11 +0000 (21:04 +0000)
src/Protocol/Diaspora.php

index 1578edb92053058da6d6d4d3cb07e1382d3f8302..384a019587f4e8282e5f14def77c467fce1a4de0 100644 (file)
@@ -2211,7 +2211,10 @@ class Diaspora
                }
 
                logger('Received participation for ID: '.$item['id'].' - Contact: '.$contact_id.' - Server: '.$server, LOGGER_DEBUG);
-               dba::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
+
+               if (!dba::exists('participation', ['iid' => $item['id'], 'server' => $server])) {
+                       dba::insert('participation', ['iid' => $item['id'], 'cid' => $contact_id, 'fid' => $person['id'], 'server' => $server]);
+               }
 
                // Send all existing comments and likes to the requesting server
                $comments = dba::p("SELECT `item`.`id`, `item`.`verb`, `contact`.`self`