From 9ac44ab6f599a01059e149ff10746f8b97694f8d Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Fri, 19 Jul 2024 02:30:59 +0000 Subject: [PATCH] Bug 24194: Making the qa script happy Tidied up a bunch there are still a couple of perltidy complaints, but I am running out of time today so attaching this patch so it doesn't get lost No more test fails, or failing patterns Signed-off-by: Chris Cormack --- Koha/Hold.pm | 2 +- circ/waitingreserves.pl | 3 ++- .../bug24194-add-ReserveExpiration-syspref.pl | 10 ++++++---- misc/cronjobs/holds/cancel_expired_holds.pl | 2 +- t/db_dependent/Hold.t | 8 +++++--- t/db_dependent/Reserves.t | 17 +++++++++++------ 6 files changed, 26 insertions(+), 16 deletions(-) mode change 100644 => 100755 installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl diff --git a/Koha/Hold.pm b/Koha/Hold.pm index cc6f422aa37..50f26d71d81 100644 --- a/Koha/Hold.pm +++ b/Koha/Hold.pm @@ -252,7 +252,7 @@ sub set_waiting { $max_pickup_delay = $rule->rule_value; } - my $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); + $new_expiration_date = dt_from_string($self->waitingdate)->clone->add( days => $max_pickup_delay ); if ( C4::Context->preference("ExcludeHolidaysFromMaxPickUpDelay") ) { my $itemtype = $self->item ? $self->item->effective_itemtype : $self->biblio->itemtype; diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index 545835455aa..9fd139aa6c9 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -100,7 +100,8 @@ while ( my $hold = $holds->next ) { next unless $hold->waitingdate; my ( $expire_year, $expire_month, $expire_day ) = split (/-/, $hold->expirationdate); - my $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ) if $hold->expirationdate; + my $calcDate; + $calcDate = Date_to_Days( $expire_year, $expire_month, $expire_day ) if $hold->expirationdate; if ($calcDate and $today > $calcDate) { if ( $op eq 'cud-cancelall' ) { diff --git a/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl b/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl old mode 100644 new mode 100755 index 82668b44ae9..f2fa5cdb188 --- a/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl +++ b/installer/data/mysql/atomicupdate/bug24194-add-ReserveExpiration-syspref.pl @@ -1,12 +1,14 @@ use Modern::Perl; return { - bug_number => "24194", + bug_number => "24194", description => "Add new system preference ReserveExpiration", - up => sub { + up => sub { my ($args) = @_; - my ($dbh, $out) = @$args{qw(dbh out)}; + my ( $dbh, $out ) = @$args{qw(dbh out)}; - $dbh->do(q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ("ReserveExpiration", 1, NULL, "Enable the use of expiration date in holds module.", "YesNo") }); + $dbh->do( + q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ("ReserveExpiration", 1, NULL, "Enable the use of expiration date in holds module.", "YesNo") } + ); }, }; diff --git a/misc/cronjobs/holds/cancel_expired_holds.pl b/misc/cronjobs/holds/cancel_expired_holds.pl index 11774b6e9a3..77808d3f351 100755 --- a/misc/cronjobs/holds/cancel_expired_holds.pl +++ b/misc/cronjobs/holds/cancel_expired_holds.pl @@ -75,7 +75,7 @@ pod2usage(1) if $help; cronlogaction({ info => $command_line_options }); -if( C4::Context->preference('ReserveExpiration') ) { +if ( C4::Context->preference('ReserveExpiration') ) { C4::Reserves::CancelExpiredReserves($reason); } diff --git a/t/db_dependent/Hold.t b/t/db_dependent/Hold.t index 1574834c4ec..08b553c08a0 100755 --- a/t/db_dependent/Hold.t +++ b/t/db_dependent/Hold.t @@ -443,8 +443,9 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 0 ); my $expirationdate = dt_from_string->add( days => 1 ); - my $hold = $builder->build_object( - { class => 'Koha::Holds', + my $hold = $builder->build_object( + { + class => 'Koha::Holds', value => { patron_expiration_date => $expirationdate } } ); @@ -456,7 +457,8 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 1 ); $hold = $builder->build_object( - { class => 'Koha::Holds', + { + class => 'Koha::Holds', value => { patron_expiration_date => $expirationdate } } ); diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 7ce536f4b4b..924dd1e0cd9 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -1426,8 +1426,9 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 1 ); my $expirationdate = dt_from_string->add( days => 1 ); - my $hold = $builder->build_object( - { class => 'Koha::Holds', + my $hold = $builder->build_object( + { + class => 'Koha::Holds', value => { expirationdate => $expirationdate } } ); @@ -1435,7 +1436,7 @@ subtest 'ReserveExpiration syspref tests' => sub { # Disable expiration date for reserves t::lib::Mocks::mock_preference( 'ReserveExpiration', 0 ); - my $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber }); + my $reverted = C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } ); is( $reverted->expirationdate, undef, "Expiration date should be removed with reserve expiration disabled" ); @@ -1443,14 +1444,18 @@ subtest 'ReserveExpiration syspref tests' => sub { t::lib::Mocks::mock_preference( 'ReserveExpiration', 1 ); $hold = $builder->build_object( - { class => 'Koha::Holds', + { + class => 'Koha::Holds', value => { expirationdate => $expirationdate } } ); - $reverted = C4::Reserves::RevertWaitingStatus({ itemnumber => $hold->itemnumber }); + $reverted = C4::Reserves::RevertWaitingStatus( { itemnumber => $hold->itemnumber } ); - is( $reverted->expirationdate, undef, "Expiration date is still removed because we can't reset to the original expiration date" ); + is( + $reverted->expirationdate, undef, + "Expiration date is still removed because we can't reset to the original expiration date" + ); }; sub count_hold_print_messages { -- 2.39.2