diff --git a/opac/opac-page.pl b/opac/opac-page.pl index 0a35c21433..49d51c4ca8 100755 --- a/opac/opac-page.pl +++ b/opac/opac-page.pl @@ -36,14 +36,18 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( my $page_id = $query->param('page_id'); -my $homebranch = $ENV{OPAC_BRANCH_DEFAULT}; +my $homebranch = $ENV{OPAC_BRANCH_DEFAULT} //= ""; if (C4::Context->userenv) { $homebranch = C4::Context->userenv->{'branch'}; } my $page = Koha::AdditionalContents->find($page_id); -if ( !$page || $page->category ne 'pages' || $page->branchcode && $page->branchcode != $homebranch || $page->location ne 'opac_only' && $page->location ne 'staff_and_opac' ) { +if ( !$page + || $page->category ne 'pages' + || $page->branchcode && $page->branchcode ne $homebranch + || $page->location ne 'opac_only' && $page->location ne 'staff_and_opac' ) +{ print $query->redirect('/cgi-bin/koha/errors/404.pl'); exit; }