Bugzilla – Attachment 3398 Details for
Bug 5932
subroutine itemdata to be replaced in C4::Serials
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
0001-Bug-5932-Remove-itemdata-sub-from-C4-Serials.patch (text/plain), 2.39 KB, created by
Colin Campbell
on 2011-03-22 15:07:18 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2011-03-22 15:07:18 UTC
Size:
2.39 KB
patch
obsolete
>From 7d3df633acfd2974625848e8db04b6650725aa13 Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Tue, 22 Mar 2011 15:01:19 +0000 >Subject: [PATCH] Bug 5932 Remove itemdata sub from C4::Serials >Content-Type: text/plain; charset="utf-8" > >C4/Serials does not need to retrieve full item data >just to check if barcode is unique. Replace with >a lighter weight subroutine make code logic clearer and >cleaner >--- > C4/Serials.pm | 35 +++++++++++++++-------------------- > 1 files changed, 15 insertions(+), 20 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index da0f4bd..32c9bcb 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -1481,9 +1481,9 @@ sub ItemizeSerials { > my $fwk = GetFrameworkCode( $data->{'biblionumber'} ); > if ( $info->{barcode} ) { > my @errors; >- my $exists = itemdata( $info->{'barcode'} ); >- push @errors, "barcode_not_unique" if ($exists); >- unless ($exists) { >+ if ( is_barcode_in_use( $info->{barcode} ) ) { >+ push @errors, 'barcode_not_unique'; >+ } else { > my $marcrecord = MARC::Record->new(); > my ( $tag, $subfield ) = GetMarcFromKohaField( "items.barcode", $fwk ); > my $newField = MARC::Field->new( "$tag", '', '', "$subfield" => $info->{barcode} ); >@@ -2338,29 +2338,24 @@ sub GetNextDate(@) { > return "$resultdate"; > } > >-=head2 itemdata >- >- $item = itemdata($barcode); >+=head2 is_barcode_in_use > >-Looks up the item with the given barcode, and returns a >-reference-to-hash containing information about that item. The keys of >-the hash are the fields from the C<items> and C<biblioitems> tables in >-the Koha database. >+Returns number of occurence of the barcode in the items table >+Can be used as a boolean test of whether the barcode has >+been deployed as yet > > =cut > >-#' >-sub itemdata { >- my ($barcode) = @_; >+sub is_barcode_in_use { >+ my $barcode = shift; > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( >- "Select * from items LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber >- WHERE barcode=?" >+ my $occurences = $dbh->selectall_arrayref( >+ 'SELECT itemnumber from items where barcode = ?', >+ {}, $barcode >+ > ); >- $sth->execute($barcode); >- my $data = $sth->fetchrow_hashref; >- $sth->finish; >- return ($data); >+ >+ return @{$occurences}; > } > > 1; >-- >1.7.4 >
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 5932
: 3398