From 5a327c4837ceec2c7bb8a90bd00aff6f7b896f29 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 10 Mar 2022 03:32:03 +0000 Subject: [PATCH] Bug 30261 - Render opac 404 for opac/tracklinks.pl This patch updates C4::Output::output_error to take an additional argument which contains an "interface" parameter, so that opac/tracklinks.pl can generate an OPAC error instead of an Intranet error. Test plan: 0. Apply patch and koha-plack --restart kohadev 1. Go to http://localhost:8081/test.pl 2. Note normal Intranet 404 error 3. Go to http://localhost:8080/cgi-bin/koha/tracklinks.pl?uri=https%3A%2F%2Ftest.com&biblionumber=29 4. Note normal Opac 404 error 4b. For extra points, note that tracklinks.pl returns a 404 instead of a 302 to the 404.pl page 5. Change 'TrackClicks' syspref to "Track" 6. Go to http://localhost:8080/cgi-bin/koha/tracklinks.pl?uri=https%3A%2F%2Ftest.com&biblionumber=29 7. Note normal Opac 404 error 7b. For extra points, note that tracklinks.pl returns a 404 instead of a 302 to the 404.pl page 8. Rejoice! --- C4/Output.pm | 6 ++++-- opac/tracklinks.pl | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index 8ea7bb51fa..c03c40354d 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -369,12 +369,14 @@ sub output_and_exit { } sub output_error { - my ( $query, $error ) = @_; + my ( $query, $error, $params ) = @_; + my $interface = 'intranet'; + $interface = 'opac' if ($params && $params->{interface} eq 'opac'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => 'errors/errorpage.tt', query => $query, - type => 'intranet', + type => $interface, authnotrequired => 1, } ); diff --git a/opac/tracklinks.pl b/opac/tracklinks.pl index ab07f033be..ce504c293b 100755 --- a/opac/tracklinks.pl +++ b/opac/tracklinks.pl @@ -35,7 +35,7 @@ my $itemnumber = $cgi->param('itemnumber') || 0; my $tracking_method = C4::Context->preference('TrackClicks'); unless ( $tracking_method ) { - output_error( $cgi, '404' ); + output_error( $cgi, '404', { interface => 'opac' } ); exit; } my $tracker = Koha::Linktracker->new( @@ -83,5 +83,5 @@ if ($uri && ($biblionumber || $itemnumber) ) { } } -output_error( $cgi, '404' ); +output_error( $cgi, '404', { interface => 'opac' } ); exit; -- 2.25.1