]> git.mxchange.org Git - friendica.git/commitdiff
Issue-4816: Avoid SQL errors / Unarchive living relais servers
authorMichael <heluecht@pirati.ca>
Wed, 11 Apr 2018 18:56:22 +0000 (18:56 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 11 Apr 2018 18:56:22 +0000 (18:56 +0000)
src/Model/Contact.php
src/Protocol/PortableContact.php

index 1354bbdb8997bf2de0e86b1bd435042895e3f03b..644662e4ecb8dc91de48dc4c72faa18ae98812b8 100644 (file)
@@ -345,9 +345,14 @@ class Contact extends BaseObject
                $fields = ['term-date' => NULL_DATE, 'archive' => false];
                dba::update('contact', $fields, ['id' => $contact['id']]);
 
-               if ($contact['url'] != '') {
+               if (!empty($contact['url'])) {
                        dba::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
                }
+
+               if (!empty($contact['batch'])) {
+                       $condition = ['batch' => $contact['batch'], 'contact-type' => ACCOUNT_TYPE_RELAY];
+                       dba::update('contact', $fields, $condition);
+               }
        }
 
        /**
index d5e9d8f8c6a09e1ed3ce231cd63bbf19d8afdbbc..20f5cb0b02ed172860e80467e478e5b99048ac55 100644 (file)
@@ -1418,7 +1418,13 @@ class PortableContact
 
                dba::delete('gserver-tag', ['gserver-id' => $gserver['id']]);
                if ($data->scope == 'tags') {
+                       // Avoid duplicates
+                       $tags = [];
                        foreach ($data->tags as $tag) {
+                               $tags[$tag] = $tag;
+                       }
+
+                       foreach ($tags as $tag) {
                                dba::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag]);
                        }
                }