Bugzilla – Attachment 114179 Details for
Bug 26328
incremental barcode generation fails when incorrectly converting strings to numbers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26328: Cast barcode from varchar to integer for incremental barcode
Bug-26328-Cast-barcode-from-varchar-to-integer-for.patch (text/plain), 1.85 KB, created by
David Cook
on 2020-12-04 05:40:53 UTC
(
hide
)
Description:
Bug 26328: Cast barcode from varchar to integer for incremental barcode
Filename:
MIME Type:
Creator:
David Cook
Created:
2020-12-04 05:40:53 UTC
Size:
1.85 KB
patch
obsolete
>From fc9a2037073d1e06f9c86ce4c59af3ae628175f9 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 4 Dec 2020 05:36:04 +0000 >Subject: [PATCH] Bug 26328: Cast barcode from varchar to integer for > incremental barcode > >Without this patch, the incremental barcode generation will >treat 978e0143019375 as having an exponent and interpret it as a very >large number. > >With this patch, the incremental barcode generation will first cast >barcode varchar strings to integers before finding a max() value. >In this case 978e0143019375 becomes 978 instead of >1.7976931348623157e308 > >Test plan: > >0. Using koha-testing-docker > >Before applying patch: > >1. Go to http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=autobarcode >2. Set to "generated in the form 1, 2, 3" >3. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 >4. Add item with barcode 978e0143019375 >5. Click "p - Barcode" >6. Note the barcode is "Inf" > >After applying patch: >1. Go to http://localhost:8081/cgi-bin/koha/cataloguing/additem.pl?biblionumber=1#additema&searchid=scs_1607059974968 >2. Click "p - Barcode" >3. Note the barcode is "39999000019194" >--- > C4/Barcodes/ValueBuilder.pm | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/C4/Barcodes/ValueBuilder.pm b/C4/Barcodes/ValueBuilder.pm >index ea8bffafa3..1716d389b9 100644 >--- a/C4/Barcodes/ValueBuilder.pm >+++ b/C4/Barcodes/ValueBuilder.pm >@@ -26,7 +26,7 @@ sub get_barcode { > my ($args) = @_; > my $nextnum; > # not the best, two catalogers could add the same barcode easily this way :/ >- my $query = "select max(abs(barcode)) from items"; >+ my $query = "select max(cast(barcode as unsigned)) from items"; > my $sth = C4::Context->dbh->prepare($query); > $sth->execute(); > while (my ($count)= $sth->fetchrow_array) { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26328
:
114179
|
131592
|
131976
|
131977