From 15a5140f3673185136d6465b300813ff1c0097d4 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 5 May 2014 15:50:45 +0000 Subject: [PATCH] Bug 10195: (follow-up) tidying up code and eliminate warning if record does not have 942$n Signed-off-by: Galen Charlton --- opac/opac-detail.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 00c6f52184..01c801f371 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -92,17 +92,20 @@ if ( ! $record ) { # redirect if opacsuppression is enabled and biblio is suppressed if (C4::Context->preference('OpacSuppression')) { + # FIXME hardcoded; the suppression flag ought to be materialized + # as a column on biblio or the like my $opacsuppressionfield = '942'; my $opacsuppressionfieldvalue = $record->field($opacsuppressionfield); # redirect to opac-blocked info page or 404? my $opacsuppressionredirect; if ( C4::Context->preference("OpacSuppressionRedirect") ) { $opacsuppressionredirect = "/cgi-bin/koha/opac-blocked.pl"; - } - else { + } else { $opacsuppressionredirect = "/cgi-bin/koha/errors/404.pl"; } - if ( $opacsuppressionfieldvalue->subfield("n") == 1) { + if ( $opacsuppressionfieldvalue && + $opacsuppressionfieldvalue->subfield("n") && + $opacsuppressionfieldvalue->subfield("n") == 1) { # if OPAC suppression by IP address if (C4::Context->preference('OpacSuppressionByIPRange')) { my $IPAddress = $ENV{'REMOTE_ADDR'}; @@ -111,8 +114,7 @@ if (C4::Context->preference('OpacSuppression')) { print $query->redirect($opacsuppressionredirect); exit; } - } - else { + } else { print $query->redirect($opacsuppressionredirect); exit; } -- 2.39.5