X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=C4%2FAuthoritiesMarc.pm;h=023cda00eb97015f1fcef4a44455990cdce2a6aa;hb=ed762eb989d5fc03cf23018ffe96b81b5bb44226;hp=c46187d5335b1dbad10c824001ebae99e275edb9;hpb=5c51edc653b4d5afd3494f48e2dc0a9508169d12;p=koha.git diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index c46187d533..023cda00eb 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -573,6 +573,7 @@ sub AddAuthority { my $sth=$dbh->prepare("update auth_header set marc=?,marcxml=? where authid=?"); $sth->execute($record->as_usmarc,$record->as_xml_record($format),$authid); $sth->finish; + $dbh->do("unlock tables"); } ModZebra($authid,'specialUpdate',"authorityserver",$oldRecord,$record); return ($authid); @@ -697,14 +698,14 @@ sub GetAuthority { =over 4 -$result= &GetAuthType( $authtypecode) -If $authtypecode is not "" then - Returns hashref to authtypecode information -else - returns ref to array of hashref information of all Authtypes +$result = &GetAuthType($authtypecode) =back +If the authority type specified by C<$authtypecode> exists, +returns a hashref of the type's fields. If the type +does not exist, returns undef. + =cut sub GetAuthType { @@ -712,19 +713,14 @@ sub GetAuthType { my $dbh=C4::Context->dbh; my $sth; if (defined $authtypecode){ # NOTE - in MARC21 framework, '' is a valid authority - # type - $sth=$dbh->prepare("select * from auth_types where authtypecode=?"); - $sth->execute($authtypecode); - } else { - $sth=$dbh->prepare("select * from auth_types"); - $sth->execute; - } - my $res=$sth->fetchall_arrayref({}); - if (scalar(@$res)==1){ - return $res->[0]; - } else { - return $res; + # type (FIXME but why?) + $sth=$dbh->prepare("select * from auth_types where authtypecode=?"); + $sth->execute($authtypecode); + if (my $res = $sth->fetchrow_hashref) { + return $res; + } } + return; } @@ -802,7 +798,7 @@ sub FindDuplicateAuthority { # build a request for SearchAuthorities my $query='at='.$authtypecode.' '; map {$query.= " and he=\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/)} $record->field($auth_tag_to_report)->subfields() if $record->field($auth_tag_to_report); - my ($error,$results)=SimpleSearch( $query, 0, 1, [ "authorityserver" ] ); + my ($error, $results, $total_hits)=SimpleSearch( $query, 0, 1, [ "authorityserver" ] ); # there is at least 1 result => return the 1st one if (@$results>0) { my $marcrecord = MARC::File::USMARC::decode($results->[0]);