Skip to content

Commit

Permalink
ignore error in migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
hannaeko committed Dec 8, 2023
1 parent a673796 commit 396bd31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/Zonemaster/Backend/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ sub _normalize_domain {
my ( $errors, $normalized_domain ) = normalize_name( $domain );

if ( scalar( @{$errors} ) ) {
die Zonemaster::Backend::Error::Internal->new( reason => "Normalizing domain returned errors.", data => $errors );
die Zonemaster::Backend::Error::Internal->new( reason => "Normalizing domain returned errors.", data => [ map { $_->string } @{$errors} ] );
}

return $normalized_domain;
Expand Down
23 changes: 14 additions & 9 deletions share/patch/patch_db_zonemaster_backend_ver_11.0.3.pl
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,24 @@ sub _update_data_nomalize_domains {
my $progress = 0;

while ( my $row = $sth1->fetchrow_hashref ) {
my $hash_id = $row->{hash_id};
my $raw_params = decode_json($row->{params});
my $domain = $raw_params->{domain};
eval {
my $hash_id = $row->{hash_id};
my $raw_params = decode_json($row->{params});
my $domain = $raw_params->{domain};

# This has never been cleaned
delete $raw_params->{user_ip};
# This has never been cleaned
delete $raw_params->{user_ip};

my $params = $db->encode_params( $raw_params );
my $fingerprint = $db->generate_fingerprint( $raw_params );
my $params = $db->encode_params( $raw_params );
my $fingerprint = $db->generate_fingerprint( $raw_params );

$domain = Zonemaster::Backend::DB::_normalize_domain( $domain );
$domain = Zonemaster::Backend::DB::_normalize_domain( $domain );

$db->dbh->do('UPDATE test_results SET domain = ?, params = ?, fingerprint = ? where hash_id = ?', undef, $domain, $params, $fingerprint, $hash_id);
$db->dbh->do('UPDATE test_results SET domain = ?, params = ?, fingerprint = ? where hash_id = ?', undef, $domain, $params, $fingerprint, $hash_id);
};
if ($@) {
warn "Caught error while updating record, ignoring: $@\n";
}
$row_done += 1;
my $new_progress = int(($row_done / $row_total) * 100);
if ( $new_progress != $progress ) {
Expand Down

0 comments on commit 396bd31

Please sign in to comment.