From 3b6c36a4f395821eb91ee207ab2819e5ce603479 Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Tue, 5 May 2009 10:36:41 +0100 Subject: [PATCH] Moved some variable definitions out of conditionals Signed-off-by: Galen Charlton --- C4/AuthoritiesMarc.pm | 62 +++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 633ced8a0e..e039b99a3f 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -526,8 +526,13 @@ sub AddAuthority { my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record # if authid empty => true add, find a new authid number - my $format= 'UNIMARCAUTH' if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC'); - $format= 'MARC21' if (uc(C4::Context->preference('marcflavour')) ne 'UNIMARC'); + my $format; + if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC') { + $format= 'UNIMARCAUTH'; + } + else { + $format= 'MARC21'; + } if ($format eq "MARC21") { if (!$record->leader) { @@ -681,23 +686,22 @@ returns xml form of record $authid sub GetAuthorityXML { # Returns MARC::XML of the authority passed in parameter. my ( $authid ) = @_; - my $format= 'UNIMARCAUTH' if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC'); - $format= 'MARC21' if (uc(C4::Context->preference('marcflavour')) ne 'UNIMARC'); - if ($format eq "MARC21") { - # for MARC21, call GetAuthority instead of - # getting the XML directly since we may - # need to fix up the location of the authority - # code -- note that this is reasonably safe - # because GetAuthorityXML is used only by the - # indexing processes like zebraqueue_start.pl - my $record = GetAuthority($authid); - return $record->as_xml_record($format); - } else { - my $dbh=C4::Context->dbh; - my $sth = $dbh->prepare("select marcxml from auth_header where authid=? " ); - $sth->execute($authid); - my ($marcxml)=$sth->fetchrow; - return $marcxml; + if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC') { + my $dbh=C4::Context->dbh; + my $sth = $dbh->prepare("select marcxml from auth_header where authid=? " ); + $sth->execute($authid); + my ($marcxml)=$sth->fetchrow; + return $marcxml; + } + else { + # for MARC21, call GetAuthority instead of + # getting the XML directly since we may + # need to fix up the location of the authority + # code -- note that this is reasonably safe + # because GetAuthorityXML is used only by the + # indexing processes like zebraqueue_start.pl + my $record = GetAuthority($authid); + return $record->as_xml_record('MARC21'); } } @@ -942,8 +946,10 @@ sub BuildSummary{ $notes.= ''.$field->subfield('a')."\n"; } foreach my $field ($record->field('4..')) { - my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : " if ($field->subfield('2')); - $see.= ''.$thesaurus.$field->subfield('a')." -- \n"; + if ($field->subfield('2')) { + my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : "; + $see.= ''.$thesaurus.$field->subfield('a')." -- \n"; + } } # see : foreach my $field ($record->field('5..')) { @@ -1220,9 +1226,10 @@ sub merge { while (my $biblionumbers=$rq->fetchrow){ my @biblionumbers=split /;/,$biblionumbers; foreach (@biblionumbers) { - my $biblionumber=$1 if ($_=~/(\d+),.*/); - my $marc=GetMarcBiblio($biblionumber); - push @reccache,$marc; + if ($_=~/(\d+),.*/) { + my $marc=GetMarcBiblio($1); + push @reccache,$marc; + } } } } else { @@ -1232,14 +1239,17 @@ sub merge { my $query; $query= "an=".$mergefrom; my $oResult = $oConnection->search(new ZOOM::Query::CCL2RPN( $query, $oConnection )); - my $count=$oResult->size() if ($oResult); + my $count = 0; + if ($oResult) { + $count=$oResult->size(); + } my $z=0; while ( $z<$count ) { my $rec; $rec=$oResult->record($z); my $marcdata = $rec->raw(); push @reccache, $marcdata; - $z++; + $z++; } $oConnection->destroy(); } -- 2.39.5