Bug 8572: invalid auth shouldn't cause error

Prior to this patch, attempting to view an invalid authority in the
OPAC gave a system error instead of a 404. With this patch, the user
will just get a 404, as is the case with invalid bibs.

To test:
1) Try to view an invalid authority by going to:
   /cgi-bin/koha/opac-authoritiesdetail.pl?authid=999999999999
   (presuming that you don't have an authority with authid 999999999999
   in your database) before and after applying this patch

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Jared Camins-Esakov 2012-08-04 13:48:00 -04:00 committed by Paul Poulain
parent b64fd7b83a
commit 2b28b9caae
1 changed files with 6 additions and 5 deletions

View File

@ -67,9 +67,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
);
my $authid = $query->param('authid');
my $record = GetAuthority( $authid );
if ( ! $record ) {
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
exit;
}
my $authtypecode = &GetAuthTypeCode( $authid );
my $record;
if ($display_hierarchy){
my $trees=BuildUnimarcHierarchies($authid);
my @trees = split /;/,$trees ;
@ -83,7 +88,6 @@ if ($display_hierarchy){
foreach my $element (@tree){
my $cell;
my $elementdata = GetAuthority($element);
$record= $elementdata if ($authid==$element);
push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid);
$cnt++;
}
@ -94,9 +98,6 @@ if ($display_hierarchy){
'loophierarchies' =>\@loophierarchies,
);
}
else {
$record = GetAuthority( $authid );
}
my $count = CountUsage($authid);