Bug 20972 - If ISBN has 10 numbers only the first 9 numbers are used
Summary: If ISBN has 10 numbers only the first 9 numbers are used
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: master
Hardware: All All
: P5 - low critical (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 7736
Blocks:
  Show dependency treegraph
 
Reported: 2018-06-21 08:44 UTC by Johan Larsson
Modified: 2019-10-14 19:57 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 20972: If ISBN has 10 numbers only the first 9 numbers are used (1014 bytes, patch)
2018-06-21 09:11 UTC, Johan Larsson
Details | Diff | Splinter Review
Signed off patch correcting ISBN extraction (1.04 KB, patch)
2018-06-22 13:52 UTC, Colin Campbell
Details | Diff | Splinter Review
Add a test case for this to Ediorder.t (1.29 KB, patch)
2018-06-22 14:15 UTC, Colin Campbell
Details | Diff | Splinter Review
Bug 20972: If ISBN has 10 numbers only the first 9 numbers are used (1.09 KB, patch)
2018-06-22 19:26 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 20972: Add a testcase for bug 20972 (1.34 KB, patch)
2018-06-22 19:26 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Larsson 2018-06-21 08:44:32 UTC
If ISBN has 10 numbers only the first 9 numbers are being added to the Edifact-message (PIA+5+3540556753:IB') 

The bug is located in Koha/Edifact/Order.pm

     elsif ( $isbn_field =~ m/(\d{9})[Xx\d]/ ) {
         $product_id   = $1; 
         $product_code = 'IB';
     }

product_id will only get the first 9 chars in the regular expression because of the placement on the parenthesis. 

The solution to this is to move the right parenthesis like below:
     elsif ( $isbn_field =~ m/(\d{9}[Xx\d])/ ) {
         $product_id   = $1; 
         $product_code = 'IB';
     }
Comment 1 Johan Larsson 2018-06-21 09:11:14 UTC
Created attachment 76225 [details] [review]
Bug 20972: If ISBN has 10 numbers only the first 9 numbers are used

If ISBN has 10 numbers only the first 9 numbers are being added to the Edifact-message (PIA+5+3540556753:IB')

This is caused by wrong positioning of capturing parentheses in a regular expression.

Sponsored-by: Gothenburg University Library
Comment 2 Colin Campbell 2018-06-22 13:52:09 UTC
Created attachment 76281 [details] [review]
Signed off patch correcting ISBN extraction

Signed off patch
Comment 3 Colin Campbell 2018-06-22 14:15:10 UTC
Created attachment 76290 [details] [review]
Add a test case for this to Ediorder.t

Add a test for this bug and ensure routine is correctly distinguishing 10 character ISBNs from 13 digit EANs
Comment 4 Katrin Fischer 2018-06-22 19:21:55 UTC
Thx for the quick sign-off and tests, Colin!
Comment 5 Katrin Fischer 2018-06-22 19:26:52 UTC
Created attachment 76303 [details] [review]
Bug 20972: If ISBN has 10 numbers only the first 9 numbers are used

If ISBN has 10 numbers only the first 9 numbers are being added to the Edifact-message (PIA+5+3540556753:IB')

This is caused by wrong positioning of capturing parentheses in a regular expression.

Sponsored-by: Gothenburg University Library
Signed-off-by: Colin Campbell <colin.campbell@ptfs-europe.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 6 Katrin Fischer 2018-06-22 19:26:56 UTC
Created attachment 76304 [details] [review]
Bug 20972: Add a testcase for bug 20972

Ensure all 10 characters of ISBN are preserved

And that ISBNs and EANs are correctly identidied in the PIA segment

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Nick Clemens 2018-06-22 22:04:57 UTC
Awesome work all!

Pushed to master for 18.11.x
Comment 8 Martin Renvoize 2018-06-27 10:32:40 UTC
Pushed to 18.05.x for 18.05.02
Comment 9 Fridolin Somers 2018-06-28 08:44:52 UTC
Pushed to 17.11.x for 17.11.08

Regular expression are a curse, they can be hell or heaven :D
Comment 10 Fridolin Somers 2018-09-24 12:58:01 UTC
Pushed to 17.05.x for 17.05.14