From 843328ccf12186c21ce1998074d1289d952aaef7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 14 Aug 2019 14:56:46 -0400 Subject: [PATCH] Bug 23329: Move error page to its own subroutine Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Martin Renvoize --- C4/Output.pm | 21 ++++++++++++++++++++- errors/404.pl | 18 +----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index b107e27606..f8f8e13583 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -31,6 +31,7 @@ use strict; use URI::Escape; use Scalar::Util qw( looks_like_number ); +use C4::Auth qw(get_template_and_user); use C4::Context; use C4::Templates; @@ -51,7 +52,7 @@ BEGIN { ); push @EXPORT, qw( &output_html_with_http_headers &output_ajax_with_http_headers &output_with_http_headers - &output_and_exit_if_error &output_and_exit + &output_and_exit_if_error &output_and_exit &output_error ); } @@ -365,6 +366,24 @@ sub output_and_exit { exit; } +sub output_error { + my ( $query, $error ) = @_; + my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => 'errors/errorpage.tt', + query => $query, + type => 'intranet', + authnotrequired => 1, + } + ); + my $admin = C4::Context->preference('KohaAdminEmailAddress'); + $template->param ( + admin => $admin, + errno => $error, + ); + output_with_http_headers $query, $cookie, $template->output, 'html', '404 Not Found'; +} + sub parametrized_url { my $url = shift || ''; # ie page.pl?ln={LANG} my $vars = shift || {}; # ie { LANG => en } diff --git a/errors/404.pl b/errors/404.pl index e5870ad83f..6d57df9352 100755 --- a/errors/404.pl +++ b/errors/404.pl @@ -18,23 +18,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); -use C4::Auth; use C4::Output; -use C4::Context; my $query = CGI->new; -my $admin = C4::Context->preference('KohaAdminEmailAddress'); -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { - template_name => 'errors/errorpage.tt', - query => $query, - type => 'intranet', - authnotrequired => 1, - debug => 1, - } -); -$template->param ( - admin => $admin, - errno => 404, -); -output_with_http_headers $query, $cookie, $template->output, 'html', '404 Not Found'; +output_error( $query, '404' ); -- 2.39.5