From: Moritz Bunkus Date: Mon, 2 Nov 2015 13:33:18 +0000 (+0100) Subject: Benutzung undefinierter Werte vermeiden X-Git-Tag: release-3.4.1~608 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8f3e8a0254bc848d02958cc5e1fcdf600d5632a8;p=kivitendo-erp.git Benutzung undefinierter Werte vermeiden --- diff --git a/SL/Auth.pm b/SL/Auth.pm index 2323a2841..788154c14 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -1120,7 +1120,7 @@ sub _parse_rights_string { push @{$cur_ary}, $token; } else { - push @{$cur_ary}, $self->{RIGHTS}->{$login}->{$token} * 1; + push @{$cur_ary}, ($self->{RIGHTS}->{$login}->{$token} // 0) * 1; } } diff --git a/SL/DATEV.pm b/SL/DATEV.pm index ca74cd287..90fa62073 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -263,7 +263,7 @@ sub _fill { my $fill_char = shift; my $alignment = shift || 'right'; - my $text_len = length $text; + my $text_len = length($text // ''); if ($field_len < $text_len) { $text = substr $text, 0, $field_len; diff --git a/SL/DBUtils.pm b/SL/DBUtils.pm index 8e1ad458a..89761443b 100644 --- a/SL/DBUtils.pm +++ b/SL/DBUtils.pm @@ -222,11 +222,11 @@ sub selectall_as_map { my %hash; if ('' eq ref $value_col) { while (my $ref = $sth->fetchrow_hashref()) { - $hash{$ref->{$key_col}} = $ref->{$value_col}; + $hash{$ref->{$key_col} // ''} = $ref->{$value_col}; } } else { while (my $ref = $sth->fetchrow_hashref()) { - $hash{$ref->{$key_col}} = { map { $_ => $ref->{$_} } @{ $value_col } }; + $hash{$ref->{$key_col} // ''} = { map { $_ => $ref->{$_} } @{ $value_col } }; } } diff --git a/SL/Menu.pm b/SL/Menu.pm index f01b341be..6bbcffb9c 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -103,7 +103,7 @@ sub build_tree { my %by_parent; # order them by parent for my $node ($self->nodes) { - push @{ $by_parent{ $node->{parent} } //= [] }, $node; + push @{ $by_parent{ $node->{parent} // '' } //= [] }, $node; } my $tree = { }; diff --git a/sql/Pg-upgrade2/defaults_datev_check.pl b/sql/Pg-upgrade2/defaults_datev_check.pl index 956bc810e..619a9fc02 100644 --- a/sql/Pg-upgrade2/defaults_datev_check.pl +++ b/sql/Pg-upgrade2/defaults_datev_check.pl @@ -22,11 +22,7 @@ sub run { # kivitendo's behaviour isn't changed by this update # if checks are not set in config set it to true foreach my $check (qw(check_on_sales_invoice check_on_purchase_invoice check_on_ar_transaction check_on_ap_transaction check_on_gl_transaction)) { - my $check_set = 1; - if ($::lx_office_conf{datev_check}->{$check} == 0 && defined ($::lx_office_conf{datev_check}->{$check})) { - $check_set = 0; - } - + my $check_set = defined($::lx_office_conf{datev_check}->{$check}) && ($::lx_office_conf{datev_check}->{$check} == 0) ? 0 : 1; my $update_column = "UPDATE defaults SET datev_$check = '$check_set';"; $self->db_query($update_column); }