From 8af30efbba638c0ea56e9248013c9beda69af8bb Mon Sep 17 00:00:00 2001 From: Martin Persson Date: Sun, 23 Aug 2015 23:30:55 +0200 Subject: [PATCH] Bug 12772 - Fix warnings This commit fixes a bunch of warnings for verbose messages which would clutter up the output. They should not affect normal excution. Sponsored-By: Halland County Library --- misc/cronjobs/overdue_notices.pl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 8a68744..7553569 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -446,17 +446,17 @@ if(@myborcatout){ ## collect everything in meaningful hashes ## my $hrBorrowers = $dbh->selectall_hashref($sqlBorrowers, 'borrowernumber'); -VERBOSE("$sqlBorrowers\nReturned " . (scalar keys $hrBorrowers) . " borrowers with issues."); +VERBOSE("$sqlBorrowers\nReturned " . (scalar keys %$hrBorrowers) . " borrowers with issues."); my $hrOverdueIssues = $dbh->selectall_hashref($sqlIssues, 'itemnumber' ); -VERBOSE("$sqlIssues\nReturned " . (scalar keys $hrOverdueIssues) . " overdue issues."); +VERBOSE("$sqlIssues\nReturned " . (scalar keys %$hrOverdueIssues) . " overdue issues."); my $arRules = $dbh->selectall_arrayref($sqlRules, { Slice => {} } ); VERBOSE("\nRule order:\nId\tBranch\tCat\tItem\tHold\tDelay\tDebarred\tLetter"); foreach my $rule (@$arRules){ $rule->{mtt} = $dbh->selectcol_arrayref($sqlMTT, undef, $rule->{overduerules_id}); - VERBOSE("$rule->{id}\t$rule->{branchcode}\t$rule->{categorycode}\t$rule->{itemtype}\t$rule->{onhold}\t$rule->{delay}\t$rule->{debarred}\t$rule->{letter}"); + VERBOSE("$rule->{overduerules_id}\t$rule->{branchcode}\t$rule->{categorycode}\t$rule->{itemtype}\t$rule->{onhold}\t$rule->{delay}\t$rule->{debarred}\t$rule->{letter}"); } my $hrReserves = $dbh->selectall_hashref($sqlReserves, 'biblionumber'); -VERBOSE("$sqlReserves\nReturned " . (scalar keys $hrReserves) . " unique reserves."); +VERBOSE("$sqlReserves\nReturned " . (scalar keys %$hrReserves) . " unique reserves."); my %hBranches; my %hChunks; # messages to send once per branch to the administrator @@ -466,7 +466,7 @@ my %hChunks; # messages to send once per branch to the administrator ## my $whichItemType = C4::Context->preference('item-level_itypes') ? 'itype' : 'itemtype'; -foreach my $in (keys $hrOverdueIssues){ +foreach my $in (keys %$hrOverdueIssues){ my $issue = $hrOverdueIssues->{$in}; VERBOSE("Processing issue $in. branchcode: $issue->{branchcode}, borrower: $issue->{borrowernumber}."); foreach my $rule(@$arRules){ @@ -498,7 +498,7 @@ foreach my $in (keys $hrOverdueIssues){ # we found the best rule to apply, let's store the branchcode/lettter combo into the borrower my $arItems = $hrBorrowers->{$issue->{borrowernumber}}{NOTICES}{$issue->{branchcode}}{$rule->{letter}}{ITEMS} ||= []; - push $arItems, $issue->{itemnumber}; + push @$arItems, $issue->{itemnumber}; # And note that we union the transport types, so IF the user set two similar alerts (except for delay and mtt), then # only one message will be sent to each of the transport specified by both rules together my $hrMtts = $hrBorrowers->{$issue->{borrowernumber}}{NOTICES}{$issue->{branchcode}}{$rule->{letter}}{MTTS} ||= {}; @@ -525,13 +525,13 @@ foreach my $in (keys $hrOverdueIssues){ ## Main loop ## VERBOSE("Main loop."); -foreach my $borrowernumber(keys $hrBorrowers){ +foreach my $borrowernumber(keys %$hrBorrowers){ if(!defined $hrBorrowers->{$borrowernumber}{NOTICES}){ VERBOSE("User $hrBorrowers->{$borrowernumber}{surname} has no notice."); next; } # for each branch - foreach my $branchcode (keys $hrBorrowers->{$borrowernumber}{NOTICES}){ + foreach my $branchcode (keys %{$hrBorrowers->{$borrowernumber}{NOTICES}}){ my $admin_email_address = $hBranches{$branchcode}{'branchemail'} || C4::Context->preference('KohaAdminEmailAddress'); if($hBranches{$branchcode}{CALENDAR}->is_holiday($date_to_run)){ VERBOSE("$date_to_run is a holiday at branch $branchcode"); @@ -539,7 +539,7 @@ foreach my $borrowernumber(keys $hrBorrowers){ } # for each letter - foreach my $lettercode (keys $hrBorrowers->{$borrowernumber}{NOTICES}{$branchcode}){ + foreach my $lettercode (keys %{$hrBorrowers->{$borrowernumber}{NOTICES}{$branchcode}}){ @emails_to_use = (); my $notice_email = C4::Members::GetNoticeEmailAddress($borrowernumber); unless ($nomail) { @@ -579,7 +579,7 @@ foreach my $borrowernumber(keys $hrBorrowers){ } # the transport types (email, sms...) - my @message_transport_types = keys $hrBorrowers->{$borrowernumber}{NOTICES}{$branchcode}{$lettercode}{MTTS}; + my @message_transport_types = keys %{$hrBorrowers->{$borrowernumber}{NOTICES}{$branchcode}{$lettercode}{MTTS}}; my $print_sent = 0; # A print notice is not yet sent for this patron for my $mtt ( @message_transport_types ) { my $letter = parse_letter( { @@ -610,7 +610,7 @@ foreach my $borrowernumber(keys $hrBorrowers){ if ($nomail) { $hChunks{$admin_email_address} ||= []; - push $hChunks{$admin_email_address}, prepare_letter_for_printing( { + push @{$hChunks{$admin_email_address}}, prepare_letter_for_printing( { letter => $letter, borrowernumber => $borrowernumber, firstname => $hrBorrowers->{$borrowernumber}->{'firstname'}, -- 1.7.10.4