@@ -744,9 +744,9 @@ sub upsert_host {
|
||
| 744 | 744 |
|
| 745 | 745 |
my $registry = load_registry(); |
| 746 | 746 |
my ($existing_host) = grep {
|
| 747 |
- (($_->{id} || '') eq $id) || (($_->{fqdn} || '') eq $fqdn)
|
|
| 747 |
+ (($_->{fqdn} || '') eq $fqdn) || (($_->{id} || '') eq $id)
|
|
| 748 | 748 |
} @{ $registry->{hosts} || [] };
|
| 749 |
- $id = clean_id($existing_host->{id} || $fqdn) if $existing_host && !length($payload->{id} || '');
|
|
| 749 |
+ $id = clean_id($existing_host->{id} || $fqdn) if $existing_host;
|
|
| 750 | 750 |
my @vhosts = defined $payload->{vhosts}
|
| 751 | 751 |
? clean_vhost_names($payload) |
| 752 | 752 |
: ($existing_host ? declared_vhost_names($existing_host) : ()); |
@@ -766,7 +766,7 @@ sub upsert_host {
|
||
| 766 | 766 |
my $response = eval {
|
| 767 | 767 |
my $replaced = 0; |
| 768 | 768 |
for my $i (0 .. $#{ $registry->{hosts} }) {
|
| 769 |
- if ($registry->{hosts}->[$i]{id} eq $id) {
|
|
| 769 |
+ if (($registry->{hosts}->[$i]{id} || '') eq $id || ($registry->{hosts}->[$i]{fqdn} || '') eq $fqdn) {
|
|
| 770 | 770 |
$registry->{hosts}->[$i] = \%host;
|
| 771 | 771 |
$replaced = 1; |
| 772 | 772 |
last; |