Bugzilla – Attachment 46449 Details for
Bug 15209
C4::Koha routines expecting a MARC::Record object should check it is defined
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15209: Check the parameter at the beginning of the subroutines
Bug-15209-Check-the-parameter-at-the-beginning-of-.patch (text/plain), 5.59 KB, created by
Kyle M Hall (khall)
on 2016-01-08 17:34:19 UTC
(
hide
)
Description:
Bug 15209: Check the parameter at the beginning of the subroutines
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-01-08 17:34:19 UTC
Size:
5.59 KB
patch
obsolete
>From 04b4946397ce439217680944ca96c11797bd0aa1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 28 Dec 2015 15:47:01 +0000 >Subject: [PATCH] Bug 15209: Check the parameter at the beginning of the > subroutines > >It seems better to check if parameters exist at the beginning of a >subroutine. >It makes the code easier to read and there is 1 indentation level less. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Koha.pm | 108 ++++++++++++++++++++++++++++++------------------------------- > 1 file changed, 54 insertions(+), 54 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index ef71d93..2e7db34 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -1475,29 +1475,27 @@ sub display_marc_indicators { > sub GetNormalizedUPC { > my ($marcrecord,$marcflavour) = @_; > >- if ($marcrecord) { >- if ($marcflavour eq 'UNIMARC') { >- my @fields = $marcrecord->field('072'); >- foreach my $field (@fields) { >- my $upc = _normalize_match_point($field->subfield('a')); >- if ($upc) { >- return $upc; >- } >+ return unless $marcrecord; >+ if ($marcflavour eq 'UNIMARC') { >+ my @fields = $marcrecord->field('072'); >+ foreach my $field (@fields) { >+ my $upc = _normalize_match_point($field->subfield('a')); >+ if ($upc) { >+ return $upc; > } >- > } >- else { # assume marc21 if not unimarc >- my @fields = $marcrecord->field('024'); >- foreach my $field (@fields) { >- my $indicator = $field->indicator(1); >- my $upc = _normalize_match_point($field->subfield('a')); >- if ($upc && $indicator == 1 ) { >- return $upc; >- } >+ >+ } >+ else { # assume marc21 if not unimarc >+ my @fields = $marcrecord->field('024'); >+ foreach my $field (@fields) { >+ my $indicator = $field->indicator(1); >+ my $upc = _normalize_match_point($field->subfield('a')); >+ if ($upc && $indicator == 1 ) { >+ return $upc; > } > } > } >- return; > } > > # Normalizes and returns the first valid ISBN found in the record >@@ -1510,60 +1508,60 @@ sub GetNormalizedISBN { > ($isbn) = split(/\|/, $isbn ); > return _isbn_cleanup($isbn); > } >- if ($marcrecord) { >- >- if ($marcflavour eq 'UNIMARC') { >- my @fields = $marcrecord->field('010'); >- foreach my $field (@fields) { >- my $isbn = $field->subfield('a'); >- if ($isbn) { >- return _isbn_cleanup($isbn); >- } >+ >+ return unless $marcrecord; >+ >+ if ($marcflavour eq 'UNIMARC') { >+ my @fields = $marcrecord->field('010'); >+ foreach my $field (@fields) { >+ my $isbn = $field->subfield('a'); >+ if ($isbn) { >+ return _isbn_cleanup($isbn); > } > } >- else { # assume marc21 if not unimarc >- my @fields = $marcrecord->field('020'); >- foreach my $field (@fields) { >- $isbn = $field->subfield('a'); >- if ($isbn) { >- return _isbn_cleanup($isbn); >- } >+ } >+ else { # assume marc21 if not unimarc >+ my @fields = $marcrecord->field('020'); >+ foreach my $field (@fields) { >+ $isbn = $field->subfield('a'); >+ if ($isbn) { >+ return _isbn_cleanup($isbn); > } > } > } >- return; > } > > sub GetNormalizedEAN { > my ($marcrecord,$marcflavour) = @_; > >- if ($marcrecord) { >- if ($marcflavour eq 'UNIMARC') { >- my @fields = $marcrecord->field('073'); >- foreach my $field (@fields) { >- my $ean = _normalize_match_point($field->subfield('a')); >- if ( $ean ) { >- return $ean; >- } >+ return unless $marcrecord; >+ >+ if ($marcflavour eq 'UNIMARC') { >+ my @fields = $marcrecord->field('073'); >+ foreach my $field (@fields) { >+ my $ean = _normalize_match_point($field->subfield('a')); >+ if ( $ean ) { >+ return $ean; > } > } >- else { # assume marc21 if not unimarc >- my @fields = $marcrecord->field('024'); >- foreach my $field (@fields) { >- my $indicator = $field->indicator(1); >- my $ean = _normalize_match_point($field->subfield('a')); >- if ( $ean && $indicator == 3 ) { >- return $ean; >- } >+ } >+ else { # assume marc21 if not unimarc >+ my @fields = $marcrecord->field('024'); >+ foreach my $field (@fields) { >+ my $indicator = $field->indicator(1); >+ my $ean = _normalize_match_point($field->subfield('a')); >+ if ( $ean && $indicator == 3 ) { >+ return $ean; > } > } > } >- return; > } > > sub GetNormalizedOCLCNumber { > my ($marcrecord,$marcflavour) = @_; >- if ($marcrecord && $marcflavour ne 'UNIMARC' ) { >+ return unless $marcrecord; >+ >+ if ($marcflavour ne 'UNIMARC' ) { > my @fields = $marcrecord->field('035'); > foreach my $field (@fields) { > my $oclc = $field->subfield('a'); >@@ -1572,8 +1570,10 @@ sub GetNormalizedOCLCNumber { > return $oclc; > } > } >+ } else { >+ # TODO for UNIMARC > } >- return; >+ return > } > > sub GetAuthvalueDropbox { >-- >2.1.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 15209
:
44963
|
46007
|
46008
|
46009
|
46447
|
46448
| 46449