]> git.mxchange.org Git - friendica.git/commitdiff
Don't delete and recreate the rows over and over again
authorMichael <heluecht@pirati.ca>
Fri, 6 Mar 2020 13:51:36 +0000 (13:51 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 6 Mar 2020 13:51:36 +0000 (13:51 +0000)
src/Model/GContact.php
static/dbstructure.config.php

index 86b6bb94cdc8c91396ccb90bea1eabbd08104d13..ae1bd665e33c1255737b287257729f25cbc0d7d6 100644 (file)
@@ -1303,7 +1303,7 @@ class GContact
                        $gcid = $gcontact['id'];
                        if (!empty($followers)) {
                                // Clear the follower list, since it will be recreated in the next step
-                               DBA::delete('gfollower', ['gcid' => $gcid]);
+                               DBA::update('gfollower', ['deleted' => true], ['gcid' => $gcid]);
                        }
 
                        $contacts = array_unique(array_merge($followers, $followings));
@@ -1317,12 +1317,16 @@ class GContact
                                                $fields = ['gcid' => $gcontact['id'], 'follower-gcid' => $gcid];
                                        }
                                        Logger::info('Set relation between contacts', $fields);
-                                       DBA::update('gfollower', $fields, $fields, true);
+                                       DBA::update('gfollower', ['deleted' => false], $fields, true);
                                        continue;
                                }
                                Logger::info('Discover new AP contact', ['url' => $contact]);
                                Worker::add(PRIORITY_LOW, 'UpdateGContact', $contact);
                        }
+                       if (!empty($followers)) {
+                               // Delete all followers that aren't undeleted
+                               DBA::delete('gfollower', ['gcid' => $gcid, 'deleted' => true]);
+                       }
                        Logger::info('AP contacts discovery finished', ['url' => $url]);
                        return;
                }
index 11695b59243ca3598abfddc5a46aba66b78ecf35..3c9bc50fb9d8f2578e3f00946da170e6ed90e82e 100755 (executable)
@@ -495,6 +495,7 @@ return [
                "fields" => [
                        "gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["gcontact" => "id"], "comment" => "global contact"],
                        "follower-gcid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["gcontact" => "id"], "comment" => "global contact of the follower"],
+                       "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 indicates that the connection has been deleted"],
                ],
                "indexes" => [
                        "PRIMARY" => ["gcid", "follower-gcid"],