Merge pull request #4822 from annando/issue-4816

Issue-4816: Avoid SQL errors / Unarchive living relais servers
This commit is contained in:
Hypolite Petovan 2018-04-12 07:13:27 -04:00 committed by GitHub
commit 33d60efd8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -345,9 +345,14 @@ class Contact extends BaseObject
$fields = ['term-date' => NULL_DATE, 'archive' => false]; $fields = ['term-date' => NULL_DATE, 'archive' => false];
dba::update('contact', $fields, ['id' => $contact['id']]); dba::update('contact', $fields, ['id' => $contact['id']]);
if ($contact['url'] != '') { if (!empty($contact['url'])) {
dba::update('contact', $fields, ['nurl' => normalise_link($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);
}
} }
/** /**

View File

@ -1418,7 +1418,14 @@ class PortableContact
dba::delete('gserver-tag', ['gserver-id' => $gserver['id']]); dba::delete('gserver-tag', ['gserver-id' => $gserver['id']]);
if ($data->scope == 'tags') { if ($data->scope == 'tags') {
// Avoid duplicates
$tags = [];
foreach ($data->tags as $tag) { foreach ($data->tags as $tag) {
$tag = strtolower($tag);
$tags[$tag] = $tag;
}
foreach ($tags as $tag) {
dba::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag]); dba::insert('gserver-tag', ['gserver-id' => $gserver['id'], 'tag' => $tag]);
} }
} }