Bug 23329: Move error page to its own subroutine

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2019-08-14 14:56:46 -04:00 committed by Martin Renvoize
parent fde00fefec
commit 7fa1cde78e
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 21 additions and 18 deletions

View File

@ -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 }

View File

@ -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' );