https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43870
Bug ID: 43870
Summary: EDIFACT message with no BGM segment stops edi_cron.pl
Initiative type: ---
Sponsorship ---
status:
Product: Koha
Version: Main
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P5 - low
Component: Acquisitions
Assignee: [email protected]
Reporter: [email protected]
QA Contact: [email protected]
Depends on: 43757
Target Milestone: ---
Follow-up to bug 43757. That bug makes Koha::Edifact->new throw
Koha::Exceptions::FileNotParsed for an empty transmission, a missing or
unsupported UNA and an interchange containing no messages, and makes
process_invoice, process_quote and process_ordrsp record the failure against
the message (status 'error' plus an edifact_errors row) and carry on.
A malformed message inside an otherwise valid interchange is not covered.
Koha::Edifact::Message->new assumes the second segment is a BGM and that at
least one segment follows the BGM and any DTM segments:
my $bgm = shift @{$data_array_ref};
my $msg_function = $bgm->elem(2);
...
while ( $data_array_ref->[0]->tag eq 'DTM' ) {
A message with no BGM dies with: Can't call method "elem" on an undefined
value. A message that ends after its BGM and DTM segments dies in the while
loop in the same way.
Koha::Edifact->message_array, which builds the Message objects, is called by
process_invoice, process_quote and process_ordrsp outside any error handling.
The exception therefore stops edi_cron.pl: the remaining messages and accounts
are not processed and the message is left in status 'processing'.
Proposed changes:
a. Koha::Edifact::Message->new throws Koha::Exceptions::FileNotParsed
("Message has no BGM segment") when the second segment is not a BGM, and the
DTM loop stops at the end of the segments.
b. The exception is raised on the first call to message_array, not when the
Koha::Edifact object is constructed.
c. process_invoice, process_quote and process_ordrsp catch it around
message_array and handle it as bug 43757 does for a failed parse: status
'error', an edifact_errors row with the reason, a log entry, and carry on with
the next message.
Test plan:
1. Add an INVOICE to edifact_messages (status 'new') whose raw_msg is:
UNA:+.? 'UNB+UNOC:3+TEST+KOHA+200101:0000+1'UNH+1+INVOIC'UNT+1+1'UNZ+1+1'
followed by a second, valid INVOICE.
2. Run misc/cronjobs/edi_cron.pl (or process_invoice on both messages).
3. Without the patch: the cron dies on the first message, which is left in
status 'processing'.
4. With the patch: the first message has status 'error' with a row in
edifact_errors ("Message has no BGM segment") and the second is processed.
Referenced Bugs:
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43757
[Bug 43757] EDIFACT parser drops syntax 4 interchanges silently and dies on a
missing UNA
--
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/