From 48d37cfa8f741274e5a48100636e3a37101f8b5a Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 30 Oct 2024 13:52:36 -0100 Subject: [PATCH] Handle error if date format is invalid --- .../PTFSEurope/ReprintsDesk/Processor/CheckAvailability.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Koha/Plugin/Com/PTFSEurope/ReprintsDesk/Processor/CheckAvailability.pm b/Koha/Plugin/Com/PTFSEurope/ReprintsDesk/Processor/CheckAvailability.pm index fdb2e0d..d3acd01 100644 --- a/Koha/Plugin/Com/PTFSEurope/ReprintsDesk/Processor/CheckAvailability.pm +++ b/Koha/Plugin/Com/PTFSEurope/ReprintsDesk/Processor/CheckAvailability.pm @@ -177,7 +177,7 @@ sub run { my $unavailable_request_to_update = Koha::ILL::Requests->find( $unavailable_id->{illrequest_id} ); # Bail if we can't price check - if ( !$unavailable_id->{standardnumber} || !$unavailable_id->{year} ) { + if ( !$unavailable_id->{standardnumber} || !$unavailable_id->{year} || $unavailable_id->{year} !~ /^\d{4}$/) { $self->debug_msg( sprintf( "Request #%d does not have a ISSN/ISBN or year. Skipping this price check.", @@ -192,6 +192,9 @@ sub run { $unavailable_request_to_update->append_to_note( "Request is missing 'year' required for price check." . $note_instructions ) unless $unavailable_id->{year}; + $unavailable_request_to_update->append_to_note( + "Request 'year' is not in expected format (YYYY) for price check. " . $note_instructions ) + unless $unavailable_id->{year} =~ /^\d{4}$/; $unavailable_request_to_update->status($status_if_unavailable_without_price); next; }