[Koha-patches] [PATCH] Moved some variable definitions out of conditionals
Galen Charlton
galen.charlton at liblime.com
Sat May 2 00:16:01 CEST 2009
Hi Colin,
When this patch is applied to HEAD, C4/AuthoritiesMarc.pm fails to compile:
perl -wc C4/AuthoritiesMarc.pm
Global symbol "$format" requires explicit package name at
C4/AuthoritiesMarc.pm line 704.
C4/AuthoritiesMarc.pm had compilation errors.
Please fix and resubmit.
See below for more comments:
On Fri, May 1, 2009 at 4:21 AM, Colin Campbell
<colin.campbell at ptfs-europe.com> wrote:
> - 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';
> + }
A more compact way of doing this is:
my $format = (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC)
? 'UNIMARCAUTH' : '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($format);
> }
> }
This is the part where the compilation error crept in.
> @@ -942,8 +946,11 @@ sub BuildSummary{
> $notes.= '<span class="note">'.$field->subfield('a')."</span>\n";
> }
> foreach my $field ($record->field('4..')) {
> - my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : " if ($field->subfield('2'));
> - $see.= '<span class="UF">'.$thesaurus.$field->subfield('a')."</span> -- \n";
> + my $thesaurus;
> + if ($field->subfield('2')) {
> + my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : ";
The second 'my $thesaurus' is redundant.
Regards,
Galen
--
Galen Charlton
VP, Research & Development, LibLime
galen.charlton at liblime.com
p: 1-888-564-2457 x709
skype: gmcharlt
More information about the Koha-patches
mailing list